Debug School


Posted on

Day -1 Dockers realted questions.

What is Docker?

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. The service has both free and premium tiers. The software that hosts the containers is called Docker Engine.
Why We need docker?

Because Docker containers encapsulate everything an application needs to run (and only those things), they allow applications to be shuttled easily between environments.
Docker enables more efficient use of system resources. Instances of containerized apps use far less memory than virtual machines, they start up ...

What is Container?
A container is a unit of software that packages code and its dependencies so the application runs quickly and reliably across computing environments.

How Container Works?

Containers are an abstraction in the application layer, whereby code and dependencies are compiled or packaged together. It is possible to run multiple containers on one machine. Each container instance shares the OS kernel with other containers, each running as an isolated process.
How to install Docker?

You can download and install Docker on multiple platforms. Refer to the following section and choose the best installation path for you.
What are the components docker?

You can download and install Docker on multiple platforms. Refer to the following section and choose the best installation path for you.
1 Docker Installation in Centos/RHEL
1.1 Method -1: How to install Docker Community Edition via YUM?
1.2 Method – 2: How to install Docker Community Edition via RPM Packages?
1.3 Method – 3: How to install Docker Community Edition via script?
2 Docker install in Ubuntu
3 How to Install Docker in RHEL8 / RHEL9 / CENTOS8 / CENTOS9?
I used the below method
Docker provides convenience scripts at
Step 1 – Download and Run the script.

$ curl -fsSL -o
$ sudo 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 is a container lifecycle commands?

What is docker pause/unpuase?

Paused / Unpaused state
So, as the container is running, there must be a way to pause it. We can do so by running the pause command. This command effectively freezes or suspends all the processes running in a container. When in a paused state, the container is unaware of its state.

docker pause container

It basically sends the SIGSTOP signal to pause the processes in the container.

Similarly, to get the paused container back on running, we’d use the docker unpause command:

docker unpause container

What is docker stop/kill?

For a container to be in a killed state, we run the docker kill command, which sends SIGKILL signals to terminate the main process immediately. This means the difference between docker stop and docker kill is that - stop can allow safe termination (within the grace period) while kill terminates immediately.
How to get inside a container?

Once you have your Docker container up and running, you can work with the environment of the Docker container in the same way you would do with an Ubuntu machine. You can access the bash or shell of the container and execute commands inside it and play around with the file system. You can build, test, and deploy your applications inside the container itself.
Predominantly, there are 3 ways to access the shell of a running container. These are -

Using the Docker run command to run a container and access its shell.
$ docker run -it --name=myubuntu ubuntu:latest bash
Using the Docker exec command to run commands in an active container.
$ docker exec -it myubuntu bash

Using the Docker start command and attach a shell to a stopped container.

$ docker container ps -a
$ docker start -ai myubuntu

How to access container from outside?

In order to make a port available to services outside of Docker, or to Docker containers which are not connected to the container's network, we can use the -P or -p flag. This creates a firewall rule which maps a container port to a port on the Docker host to the outside world.
Accesss from Outside === Network

65 docker inspect 955a249cbf71
66 docker ps
67 curl
68 ping ""
69 history

What is the rule for container is running?

The docker run command first creates a writeable container layer over the specified image, and then starts it using the specified command.
To check the status of a specific container you can use the docker ps command to list all running containers and filter them using grep to show the specific container you're interested in.

Top comments (0)