Debug School

Tv Suneel
Tv Suneel

Posted on

Day 1 Assignment

What is Docker?
Ans: Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime. Using Docker, you can quickly deploy and scale applications into any environment and know your code will run.

Why We need docker?
Ans:
Consistent & Isolated Environment
Rapid Application Deployment
Ensures Scalability & Flexibility
Better Portability
Cost-Effective
In-Built Version Control System
Security

What is Container?
Ans: A container is a software code package containing an application's code, its libraries, and other dependencies. Containerization makes your applications portable so that the same code can run on any device. Also, a container is a sandboxed process on your machine that is isolated from all other processes on the host machine. That isolation leverages kernel namespaces and cgroups, features that have been in Linux for a long time. Docker has worked to make these capabilities approachable and easy to use.

To summarize, a container:
Is a runnable instance of an image. You can create, start, stop, move, or delete a container using the DockerAPI or CLI.
Can be run on local machines, virtual machines or deployed to the cloud.
Is portable (can be run on any OS).
Is isolated from other containers and runs its own software, binaries, and configurations.

How Container Works?
ANS: Docker allocates a read-write filesystem to the container, as its final layer. This allows a running container to create or modify files and directories in its local filesystem. Docker creates a network interface to connect the container to the default network, since you did not specify any networking options.

**How to install Docker?
**Ans: There are 3 different steps
Docker provides convenience scripts at get.docker.com.
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?
Ans:

  • Docker engine
  • Docker image
  • Registry,
  • Container

What is a container lifecycle commands?
ANS: Common Commands in Docker Container Lifecycle Management

  • Create Container
  • Start Container
  • Run Container
  • Pause Container
  • Stop Container
  • Delete Container
  • Kill Container

What is docker pause/unpuase?
Ans: The docker pause command suspends all processes in the specified containers. You can pause your Docker Desktop session when you are not actively using it and save CPU resources on your machine.

What is docker stop/kill?
Ans: When docker stopped status of the code will be 0, but when killed exit code will be 137. Stop means grace full exit after all child process get exit, when we kill, it’s a force full stop.

How to get inside a container?
Ans: By using exec -it command we can access the files inside a container in a interactive mode using shell.

How to access container from outside?
Ans:
Get a container ip address using inspect command, curl http://ipaddress.

What is the rule for container is running?
Ans: Check the process id, if PID1 is running then container is running.

Top comments (0)