Steps to Docker

Step by Step guide to work with dockers 

Docker Terminology:

  1. docker containers: directories containing everything-your-application
  2. docker engine : Daemon used to manage docker containers on the host it runs
  3. docker CLI: used to command and communicate with the docker engine
  4. docker images: snapshots of containers or base OS (e.g. Ubuntu) images
  5. docker image index: a repository (public or private) for docker images.


To start a container with docker command (docker cli) you need base (docker image).Docker images establish the base of docker containers from which everything starts to form. They are very similar to default operating-system disk images which are used to run applications on servers or desktop computers. They make a solid, consistent and dependable base with everything that is needed to run the applications.

As more layers (tools, applications etc.) are added on top of the base, new images can be formed by committing these changes. When a new container gets created from a saved (i.e. committed) image, things continue from where they left off. And the union file system brings all the layers together as a single entity when you work with a container.

Dockerfiles are scripts containing a successive series of instructions, directions, and commands which are to be executed to form a new docker image. Each command executed translates to a new layer of the onion, forming the end product. They basically replace the process of doing everything manually and repeatedly. When a Dockerfile is finished executing, you end up having formed an image, which then you use to start (i.e. create) a new container.

Install and Use Docker

Docker requires a 64-bit installation and a 3.10 Linux kernel is the minimum requirement for Docker. Kernels older than 3.10 lack some of the features required to run Docker containers. These older versions are known to have bugs which cause data loss and frequently panic under certain conditions.

Warning: Installing a newer kernel might not be enough for some distributions which provide packages which are too old or incompatible with newer kernels.

$ uname -r
Add the yum repo.
$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]name=Docker Repository


Install the Docker package.

$ sudo yum install docker-engine

Start the Docker daemon.

$ sudo service docker start

To ensure Docker starts when you boot your system, do the following:

  $ sudo chkconfig docker on

Usage Syntax:

Using docker (via CLI) consists of passing it a chain of options and commands followed by arguments. Please note that docker needs sudo privileges in order to work.

$ sudo docker [option] [command] [arguments]

Let’s begin with seeing all available commands docker have.

Ask docker for a list of all available commands:

$ sudo docker

All currently (as of 0.7.1) available commands:


Check out system-wide information and docker version:

# For system-wide information on docker:

$ sudo docker info

# For docker version:

$ sudo docker version

Searching for a docker image:*

# Usage: sudo docker search [image name]
$ sudo docker search centos

Downloading (PULLing) an image:

# Usage: sudo docker pull [image name]
$ sudo docker pull centos

Listing images:

# Example: sudo docker images
$ sudo docker images

Running a container: 

You can run multiple containers with same image. It gives its own identity number for each container.

$ docker run -t -i centos /bin/bash
here –t and –i are flags
-t, --tty                     Allocate a pseudo-TTY
-i, --interactive             Keep STDIN open even if not attached

Exit to stop container.

$ docker run -d centos

Here the -d flag tells Docker to run the container in the background.

Listing all current containers:

By default, you can use the following to list all running containers:

$ sudo docker ps

To have a list of both running and non-running ones, use:

$ sudo docker ps -l


bc533791f3f5  centos:latest  /bin/bash Up 2 seconds  nostalgic_morse

Here you can observe there is unique identifier for each container. If you want to stop or remove a listed container you need to use that identifier.

Stopping a container:

To stop a container’s process from running:

# Usage: sudo docker stop [container ID]
$ sudo docker stop bc533791f3f5

Removing / Deleting a container:

Using the ID of a container, you can delete one with rm.

# Usage: sudo docker rm [container ID]
$ sudo docker rm bc533791f3f5