Get to know how docker works

Divya P
featurepreneur
Published in
3 min readOct 15, 2021

Exploring Docker

The major problem most of the developers face is the application runs perfectly in the developer machine but not in the client machine. Here comes the docker to fix all these issues.

As the logo symbolizes, it is a container. Usually, we load all the goods to a container to export. Similarly, we are loading all the program files to a container that runs on a docker daemon. So the application runs similarly on all the operating systems.

How Docker works

Difference between Docker and Virtual Machine :

An application can run on different operating systems. For this, we can use either Docker or a Virtual machine. Docker containers do not occupy more space, RAM, and time. Whereas Virtual machine occupies user space and kernel space of an operating system. VM runs on a hypervisor (VMware, Virtualbox) but docker can be installed directly on the host operating system.

Difference between Docker and Virtual Machine

Let us start with docker.

Install docker in your Linux operating system

sudo snap install docker 

Check the version

docker --version

Try running hello-world to check docker:

sudo docker run hello-world

Create a container using command-line:

Syntax:

docker create [OPTIONS] IMAGE [COMMAND] [ARG...]

Command:

sudo docker create -it --name Container_A alpine:latest

alpine is the image name. If the image is not available locally it directly pulls from Dockerhub.

You can run the container by mentioning the image attached to it.

sudo docker run -itd <image-name>

To stop the running container the stop command is used with the container_id.

sudo docker stop <container_id>

You can’t attach a stopped container. So, first, start the container to attach it. You can surf inside the container. To see all the files and logs.

sudo docker start <container_id>
sudo docker attach <container_id>

exec is used to perform commands on the container.

sudo docker exec -it <container_id> ls

Thanks for reading! Hope you found it helpful. Follow for more future articles.

Learn some of the basic docker commands here:

Find me here:

--

--