Containers are based on images, and you better should know a bit about images as well.
So before running a container, the container image is fetched and stored locally.
All images are stored on the container host by default, and you can use Docker images
for a list of current images.
The command docker inspect images is a cool command because it will show you exactly what
happens while starting the container.
And if you don't need a specific container image anymore, you can use docker rmi followed
by the name of the image to remove the image.
It's also possible to work with custom images.
To do so, you would use the docker file.
On Red Hat based Popman systems, container file is commonly used as an alternative name
for docker file.
For an example, you can check the docker file in the course git repository.
Now you can build your own container image based on the instructions in the docker file.
Use docker build minus T image name.
That's the name of the image that you want to create.
Dot slash name of the docker file directory to build the container image.
And after creating the image is added to the list of images on your system.
Let me show you.
So to start with, I want to show you docker images.
These are the images that have been fetched so far.
And do you see that?
The busy box is only four megabytes.
Now let's use docker inspect on nginx.
Well I would like to use it in a slightly different way.
Let's use docker image inspect on nginx.
Because docker inspect, you don't tell docker what to expect.
So it needs to guess.
Docker image inspect, it knows that you want to inspect an image.
Without the image, it will also find the container with the name nginx and it will show you the
configuration of that.
Now here we can see the configuration behind the container image.
With the path variable, with the default command that it is running.
And more about what the container image is doing.
And that can be very useful to figure out what is going to happen before you actually
do it.
Now let's go into the course git repository.
To start with, I need to make it available here using git clone https://github.com
slash sander van vugt slash linux plus.
All right, so in the linux plus git repository, there's a subdirectory with the name dockerfile
in which you find a dockerfile.
So what is in this dockerfile?
Well, a simple example of a dockerfile specifying from alpine.
So choosing alpine, one of these base cloud image as a foundational image.
Then we have the maintainer.
That's for politeness sake.
It's open source and an open source is always nice if you can find your original developer.
Then we use add to add a file.
It's kind of a dummy here, but it's an interesting way to show you how you can add a file to
your container image.
Then it is installing some cool software.
The run command is running while you build your custom container image.
So apk is the alpine package manager is going to add bash as well as nmap.
Then the entry point is specifying the default command and this entry point works with the
argument minus sn 172.17.0.0.
So if I want to use it, I can use docker build minus t altmap.
Minus t is a tag and this tag is really the name that you are going to assign and I'm
doing that on dot.
Now this is telling you that the legacy builder is deprecated.
Please ignore that for now it's still used.
Now if I use docker images, now we can see that altmap is now available.
And if I use docker run altmap, it is going to run its primary application.
And this primary application is nmap and here you can see that nmap is doing its work and
might give us a result in a little bit.
It's not about the result of the nmap application.
It's about the fact that I created a container image that is running this application.
Why would you want to do that?
Well, containers are cool because they run in complete isolation.
No risk for any other applications in your environment.