Docker

Docker-Context

Docker has a client-server architecture. When you want to write your own docker-image you can write a dockerfile (just a file named “dockerfile”, although you could give it any name and pass that name explicitly with the -f flag) containing the necessary commands. You build an image by using the “build” command:

docker build -t networkmonitoring .

-t is for tagging, i.e. here you name the image “networkmonitoring”. Most important is the dot “.” at the end of the line. It means that docker will look here, in the present directory, for the dockerfile and that it will tar all the content of the current directory and send it to the docker-server. So the dot denotes the so-called docker-context. You cannot use the COPY-command to add files or directories to your image which are not part of the docker-context. You want to exclude everything which you don’t want to be sent to the resulting docker image. This can be achieved by creating a file called “.dockerignore” in which you simply enumerate all the items you want toe exclude. 

How to list all available images?

docker images

How to run the image or rather container interactively?

docker run -i -t networkmonitoring bash

How to access network device of host?

docker run --net=host -i -t networkmonitoring bash

How to list all containers (running or stopped) and write them to row?

docker container ls -a | awk '{ ORS="" } {print $1; print " "}'
#docker container rm .....

Was this helpful?

0 / 0

Cookie Consent with Real Cookie Banner