Docker: easy to build your programs

You may have heard of Docker, but if you’ve never used it before, this post will be good for your first step.

Why do people use Docker?

Docker can simplify the download process. For example, if you try to execute Python in your local, you should find a Python package. After you get the package, you click it and install Python which is executable. However, using docker, you just type in docker run -it python.

python

You can use Python right away!

What is Docker?

Docker use containers. In a container, there are programs to run a particular service. It means each service has a container so it is convenient to manage for users and distribute for developers. Each container is independent because of cgroups (manage system resources) and namespaces (isolate every process). You can guess the OS for Docker because they are in Linux. If you type docker version on CLI, there is a sentence: “OS/Arch: linux/amd64” for Docker Engine.

You may think this architecture is similar to using virtual machines, but it is definitely different. Each virtual machine has own guest OS and Hypervisor is needed to run virtual machines. However, there is no guest OS in Docker containers and they are managed by Docker Engine so you can easily get in touch every container on your host OS. Therefore, using Docker containers are much less overhead compared to using virtual machines. (An image in this website could be helpful for your understanding: VM and Docker.)

Every Docker container are built from a Docker image. You can see the sentence Unable to find image 'python:latest' locally in the above image. It means you do not have a Python Docker image in your local. It is essential to get the image first before executing a service you want. The next sentence latest: Pulling from library/python means downloading an actual Python Docker image from Docker Hub. (Docker Hub is a storage for Docker images.)

process

All the commands you type on CLI is executing through Docker Server (or Docker Daemon). It checks if the image exists in a cache (If there is no image, Docker Server pulls it from Docker Hub.) and makes a container using the image.

References


💬 Any comments and suggestions will be appreciated.

Leave a comment