It is time to know our containers in greater depth.
First we have the list of containers. Just to
avoid any confusion, we have run an Ubuntu container
after the context of last demo.
Let's get more information about it with docker inspect command,
followed by the container name, what we get as
output is the JSON description of the container.
We don't need to be intimidated by the sheer
amount of information as we will interpret them one by one.
Starting from the top, we have
container id provided by Docker, timestamp of
container creation, path where the container is
running, no arguments since we haven't provided any.
In the State bracket of the container, we have
indications of the fact that our container is in
running state and not paused or restarting or dead.
Then it has not been killed by going out of
memory, it's process id on Ubuntu is 694.
Then we have information about the image in terms of image
digest, and we have various paths such as host path,
log path and configuration path.
Then we have another bunch of information, where most of it
is irrelevant to this particular container.
So they are either null or empty, but which do matter
are the name of the container and the fact that it
has not restarted yet. Following this, we also
have Network, Volume and other information, which
might be useful to you once we proceed further in this course.
For now, we can focus on finding
specific information from the inspect command,
since even if you get completely familiar with all
the attributes, reading them every time can be really daunting.
Let's use --format flag with our
inspect command and narrow down the results to just IP address.
We can do this by narrowing the
range to networks and under Network Settings,
choosing the IP address field.
There we go, we have the IP address of our container.
Next is the commit command. To effectively use that command we
need to make at least one change to the container's
state after it is created from the image.
Just to remind you this ubuntu container is created from
the same image that we had pushed on our Docker Hub repo.
Let's execute it with bash, you should
already be used to this command by now.
Let's verify by listing out the directories.
Yes, we are in the container.
Now let's run an update.
The purpose here is just change the state of container
from when it was created.
Once the update is complete, let's exit it.
Now let's use docker commit command, followed by the container name
which is my-ubuntu and update name in the format
of Docker Hub repo images. We have kept it as
updated-ubuntu:1.0. Once we enter it, the update
will be committed to our Docker Hub repo.
As you may have guessed, it is essential for us to be
logged into our Docker Hub account to use this demo.
The updated container is committed as the image
as its read/write layer turns read only and
is tagged on top of previous layers of the former image.
So instead of containers, if we list out the images,
we can find the updated one which can
be directly run as a container and we won't have
to rerun the update command.
This helps maintaining the versions of Docker Images.
In next lecture, we will learn about port mapping.