Kubernetes - Day - 02 - PID/Signals/Mount
Docker Pull the details from docker register. docker pull nginx its hub repository. Want to run the image which is pulled. docker run -d --name web-demo-test nginx [ You will get the ID ] --> d for detatched mode --> Conatiner is nothing but THE RUNNING INSTANCE OF THE IMAGE . --> From one image , we can run many instance. docker ps [ all the alive running containers ] docker ps -a [ all the…
Kubernetes is a platform for managing containerized applications. When pulling an Nginx image from Docker Hub, it can be run in detached mode using the `docker run` command. Containers are running instances of images, and multiple containers can be created from a single image.
To manage processes within a container, understanding processes and their IDs is essential. A process is a running instance of a program, which consumes memory slots. The first process, PID 1, has no parent process. All other processes are children of PID 1.
Using commands like `ps aux` and `pstree`, we can view a snapshot of all processes and their relationships in a tree structure. The `docker ps` command lists all running containers. To inspect a container's process ID, use `docker inspect --format "{{ .state.Pid }}" <container_id>`.
When a container process receives the SIGTERM signal, it performs a graceful shutdown, allowing it to clean up resources. If the process doesn't respond to SIGTERM, a SIGKILL signal can forcefully terminate it. Sending the SIGUP signal to a sleeping container resumes its operation without restarting.
Mounting is a concept similar to creating links or symbolic links in Windows. It allows the container to access files and directories from the host machine. Container processes inherit the host machine's process ID, enabling them to interact with the host's resources.
Namespaces, such as PID namespaces, provide isolation for processes, preventing conflicts between containers and the host. The container shares the host's kernel, and its processes utilize the same kernel resources. Deleting an image with running containers is not possible, as the container relies on the image's contents.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.