What is Docker?
Docker is container management tool.
Docker is an open platform for developing, shipping, and running applications. It helps to reduce cost, time and improve software quality.
Why We need docker?
Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.
What is Container?
A container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI. You can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state.
Container is a software solution that wraps your software process or microservice to make it executable in all computing environments. In general, you can store all kinds of executable files in containers, for example, configuration files, software code, libraries, and binary programs
How Container Works?
Containers rely on virtual isolation to deploy and run applications that access a shared OS kernel without the need for VMs. Containers hold all the necessary components, such as files, libraries and environment variables, to run desired software without worrying about platform compatibility.
How to install Docker?
Step 1 – Download and Run the script.
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
Step 2 – Enable Docker
$ sudo systemctl enable docker
Step 3 – Start Docker
$ sudo systemctl start docker
Step 4 – Verify that docker is installed correctly by running the hello-world image.
$ sudo docker run hello-world
What are the components docker?
• Server - the Docker daemon (dockerd), which is responsible for creating and managing containers.
• Rest API - establishes communication between programs and Docker and instructs dockerd what to do.
• Command Line Interface (CLI) - used for running Docker commands.
What is a container lifecycle commands?
CREATE -> START -> STOP -> START -> RESTART -> PAUSE -> UNPAUSE -> KILL -> REMO
What is docker pause/unpuase?
The docker pause and docker unpause commands are used to pause and unpause a running container, respectively. This command can be useful for temporarily suspending the execution of a container while preserving its state.
Docker pause container
Docker unpause container
What is docker stop/kill?
The docker stop command stops the container gracefully and provides a safe way out.
The docker kill command terminates the entry point process abruptly. The docker kill command causes an unsafe exit.
If a docker stop command fails to terminate a process within the specified timeout, the Docker issues a kill command implicitly and immediately.
How to get inside a container?
The docker exec command allows you to run commands inside a running container.
To see how the exec command works and how it can be used to enter the container shell, first, start a new container.
exec - you can execute any executables inside a container.
How to access container from outside
By using network
docker inspect 955a249cbf71
What is the rule for container is running?
• PID1 has to run with anything (because no kernel in the container) which should not be excited.
• The container, by default, runs in the foreground unless explicitly detached using the -d flag.
The container runs as long as the specified command keeps running and then stops.