Docker

What are the containers in docker system?

Whenever we search about containers on the “Internet, we often end up having a comparison of the same with virtual machines. But the thing is that a container is a lot different from VMs. Today, we are going to learn about “containers in docker“.

Points about containers as compared to virtual machines:

  • They are just a process on the host operating system.
  • They are limited to resources what they can use.
  • They will stop as soon as the process as which they are running.

Note: More precisely, it is just a restricted process running on a host operating system.

With the following steps, we can easily understand about containers.

Step 1: First of all, we have to run a container and in our case, we have created an “nginx” container which is named as “nginx-test” mapped to port 80 of the host system and is running as a daemon/server. For reference check the screenshot below.

Run nginx container
Run nginx container

Step 2: Now check, whether the container created is running properly or not and from the photo below we can confirm that it is running smoothly.

Check running nginx container
Check running nginx container

Step 3: Important point, this step is going to assure that the running container is nothing but a “process” on the host operating system.

From the picture below, we have used the “ps -aux | grep nginx” command to check the running processes on the host OS and piping out the result of “ps -aux” to “grep nginx” which will filter out only the processes named as “nginx” out of all the running process.

Careful, only the first 2 lines from the picture below are important, the 3rd one is the “ps -aux | grep nginx” command itself.

Nginx container running as a process on host OS
Nginx container running as a process on host OS

So, from the above we can confirm that the “nginx container is running as a process” on the host operating sytem.

Step 4: Now, stop the running container using the commands below.

Stop the nginx container
Stop the nginx container

Step 5: Now, if we run the “ps -aux | grep nginx” command again, we can see there is no process named as “nginx” is running on the host OS.

This confirms about the fact that the “containers are nothing but a process on host OS“.

Check running nginx container
Check running nginx container

To gain more about docker, follow -> Learn Docker

Comment here