Debug School

Gaurav Pathak
Gaurav Pathak

Posted on

Day 1 Docker - Assignment- By Gaurav Pathak

What is Docker?

Docker is a container management tool. It allow developers ,admins etc. to easily deploy their application in a container.

Why We need docker?

Docker allows you to instantly create and manage containers with ease, which facilitates faster deployments. Also when compared with Physical Server/Virtual server, docker help us in cutting cost, saves time and improve software development quality. It provides a complete application isolation by provisioning container on fly within few seconds.

What is Container?

A container is a runtime instance of a Docker image.

How Container Works?

Containers bundle the application along with its dependency packages. It kind of providing a standalone environment to run the specific application.

How to install Docker?

We can use below scripts 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

What are the components of docker?

  1. Docker Engine (Docker Client + DockerD)
  2. Docker Images
  3. Docker Registry
  4. Container

What is a container lifecycle commands?

docker create image(httpd)
docker start containerId
docker stop container nameorId
docker restart
docker pause
docker unpause
docker kill ex:- docker kill containerId
docker remove ex:- docker rm containerId

What is docker pause/unpause?

The docker pause command is used to suspend all processes in the specified containers.
The docker unpause command un-suspends all processes in the specified containers.

What is docker stop/kill?

Docker stop command sends SIGTERM signal to running container process.
Docker stop command will gracefully terminate the container making sure that all child process will gracefully end up before container will shutdown. It return process exited code as 0 upon successful termination.

Docker kill command is kind of similar to docker stop command however it sends SIGKILL signal to our running container process. SIGKILL signal immediately shuts the container down without taking any pause.

How to get inside a container?

We can get inside a container using SHELL.
We can use docker exec command. This will let us to run arbitrary commands inside an existing container. Ex - docker exec 6d77829ff395 ps -eaf .
6d77829ff395 - Container Id for an ubuntu container.
To exec command in interactive mode we can use command
docker exec -it 6d77829ff395.

How to access container from outside?

To access container from outside we need NETWORK.
Use docker inspect command to get container IP address and follow the below steps
docker inspect 955a249cbf71
docker ps
curl http://172.17.0.9
ping "172.17.0.9"

What is the rule for container is running?

Container is running AS LONG AS PID1 is running Anything

Top comments (0)