Docker container

The Docker containers are running instances of a Docker image. Docker provides CLI commands to run, start, stop, move, or delete a container. You can set environment variables and provide configuration for the network from a container. The containers will get their own network configuration and filesystem. Each container process has its own isolated process space using kernel features that are ensured by Docker at runtime. The Docker containers use the kernel of the host operating system at runtime. They share the host kernel with other containers running on the same operating system host. Even the containers are initiated from the same Docker image and they have own specific resource allocation, such as memory and CPU.

Let's see the following diagram about the Docker container:

As you can see, Docker Engine manages the Docker containers, and a Docker container is nothing but a running instance of a Docker image that has an application and associated library dependencies.

Let's see how to create a Docker container from a Docker image using the following command:

$ docker run hello-world  

The preceding command has three parts:

  • docker: It is Docker Engine and used to run a Docker program. It tells to the operating system that you are running for the docker program.
  • run: It is used to create and run a docker container.
  • hello-world: It is the name of an image. You need to specify the name of an image that is to load into the container.

So, we have discussed that each container has its own copy of resources, such kernel of host operating system, RAM, and file system. How are we going to do that? We can do that by using Dockerfile. Let's discuss how to create Dockerfile in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.109.234