Getting Started with Docker Containers and Docker Images

This article is a continuation of the previous article If you are new to Docker containers or Docker images I highly recommend going to the previous article. If you already been there or you know about the basic details of docker containers and why we need them, then stay tuned.

In this article, we will be practicing a few commands on Docker and will try to understand how things work on the background.


  1. Basic understanding of docker containers.
  2. Docker installed on the machine (Skip this, if you don’t want to practice the commands right now)

Don’t have a docker installed on your machine? No worries you can still be able to practice commands. Read this for more details.

Docker Commands

$ docker version

This command will give you the detail about the version. As highlighted you can see two versions Client and Server(also called Daemon). Don’t worry about the client and Server or Daemon now. You will get to know later in this article.

$ docker info
docker image and containers

This is also a good command to see how things are on your docker like in the above image you can see the details of Containers, Images. Currently, there are no containers and images in the docker.

Lets go and create our first container (Of-course, The Hello World)

$  docker run hello-world
docker image

The Run command is the very important command, the above command says, “Docker run a container, run that container based on hello-world image”.

Now you must be thinking, that what is that hello-world image, I didn’t have or created an image with name hello-world. How did I get the output? Hold on. You will get answers to all your questions.

Steps performed by Docker to give you the output.

  1. The Docker didn’t find this image locally. Then, the docker client contacted the Docker daemon(server).
  2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
  3. The Docker daemon created a new container from that image and run the executable that produces the output.
  4. The Docker daemon sends the output to the Docker client which is then sent to the terminal.
  5. Then the container exited. (As this is the simple container, basically a short-lived container.
$ docker ps
$ docker ps -a

docker ps (to check which containers are running)
docker ps -a (to check which containers are running and was running)

In the above image, you can see that our container “hello-world” executed and then exited. You can now go again and run the docker info command. You can see

Containers: 1
   Running: 0
   Paused: 0
   Stopped: 1
Images: 1
$ docker images

This command will list all the images present locally. Also, shows some other details like Repository name, Image ID (Hash of the Image, or unique ID), etc.

I think that’s a good start with the docker container images. Keep practicing the commands for hands-on. Stay tuned with the next articles and go know more about Docker.

Leave a Comment

Your email address will not be published.