A quick guide to docker container creation

quick guide to docker container

lets create a docker container with Ubuntu operating system. You can choose the OS of your choice. We choose to use docker over virtual box because docker container are too lightweight compare to virtual box create with vagrant. Follow the following easy steps and you are done

1. Pull the image:

we need the image of the operating system we will use in our container. Its just like installing a windows or Ubuntu operating system in your system. Consider your laptop as a container and the operating system as an image. To get the image go to dockerhub and search for the image you want or simply use this command. If you are confused about what command to use. The command will also be provided in the docker hub image descriptions page.

docker pull ubuntu

2. Create a container

It is going to take some time for the image file to download. After it is downloaded create a container with the bellow docker command. The command will created a docker container with ubuntu OS.

docker run -it ubuntu

And the docker container with Ubuntu is ready to run.

3. Get container list and start the one you want

To get the containers list use the bellow command

docker ps -a

This will show the dockers containers with some details like ID, Names and other details for now we will just require ID or the Names to start the container

Lets start the container

docker start <container_Name or Container_ID>

We have started the docker container to check the running container just type

docker ps

in step 3 we used -a to get all the containers list but not using it will give the running containers.


Get into the created container:

Now everything is ready . What everyone would expect or worry about is how to get into that container. Use the following command, which will take you to the respective container and open bash shell.

docker exec -it <container_id or Name> /bin/bash

Some Reminder:

Run the command as root user or use sudo else you may run into some error message.


Creating a docker container is very easy and take fewer time than vagrant. If there is any problem or doubts or got some error please comment bellow. In future I will also try to write or talk about why use the docker over vagrant

Leave a Reply