DEV Community

technonotes-hacker
technonotes-hacker

Posted on

Kubernetes - Day - 02 - PID/Signals/Mount

Docker

  • Pull the details from docker register.
docker pull nginx
Enter fullscreen mode Exit fullscreen mode
  • its hub repository.
  • Want to run the image which is pulled.
docker run -d --name web-demo-test nginx [ You will get the ID ]
Enter fullscreen mode Exit fullscreen mode

--> 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 running containers , NOT RUNNING but exited ]
Enter fullscreen mode Exit fullscreen mode

--> -ps [ process status ]

What is process ?

  • Running instance of a program.

what is program ?

  • Its in storage/memory, once it runs goes to RAM.
  • In RAM, some slot will be assigned to that process.

--> First running process will be allocate PID as 1.
--> No parents will be there for 1.
--> all other process will be the child of it.

ps aux [ snapshot of all process ]
pstree [ In tree structure ]
pstree -p [ PID will be displayed ]

Enter fullscreen mode Exit fullscreen mode

--> docker is a container.
--> Inside docker , some application is going to RUN , that will also have the PID.

docker -ps a
ps aux | grep nginx
docker exec -it <container id from docker -ps a> bash
Enter fullscreen mode Exit fullscreen mode
  • Inside the container when I try to install ps ( sudo apt install procps ) then PID is assigned.
  • Now nginx is running inside the container with different PID , and in the host , when we check with PID its running with different PID. But the container is running inside the HOST only.

Now Lets try to kill,

  • kill the nginx with PID in the host.
  • When we check "docker ps -a" its shows like "Exited".
  • That means, the process which is running inside the container is using the HOST machine kernel.


docker images [ Display list of images ]
docker rmi <image id> [ It won't delete if the image is running ]
Enter fullscreen mode Exit fullscreen mode

What is namespace ?

  • PID is a namespace.
  • its like a separation from others.
  • even a domain name is a namespace.
- docker inspect --format '{{ .state.Pid }}' web-demo-test [ This will give the process id ]
- ls -l /proc/<pid>/ns
Enter fullscreen mode Exit fullscreen mode

SIGTERM

  • Terminate --> Graceful shutdown --> 15.
  • Forefull termination --> 09 --> No clean up process --> SIGKILL.
  • control + c --> 02
  • Without stopping the application or long running daemon process , ssh / nginx , we can update without restarting --> 01 -->SIGUP.
  • Pause a process --> 19
  • SIGCONT --> 18
- docker logs -f <container_id> [ To get the logs of the container ]
Enter fullscreen mode Exit fullscreen mode
  • Create a small python program in container like below , import time while True: print("Hi") time.sleep(1)

FILE PERMISSION / BINDING

  • Mount ? What is mount ?

  • In the same concept , we have "LINK" in windows eg., shotcut.
  • Symlink.
  • Even RBAC we can set.

Notes :

  1. head --> It will show the
  2. Image is also a OS. Image ஓட running instanceதான் Container.
  3. Container won't have size [ COW ] Copy on write. The Container will refer all from images.
  4. So only we can't delete a image when a container is running. ( When the application in the container creates some files , that only will have the size ).
  5. Daemon process --> running in the back-ground.
  6. systemd --> what is "d" here ? No one knows.
  7. Containerகுள்ள ஓடுற Process ID வந்து நம்ம 1ல தான் start ஆகுது , but அதே process , host machineல , வேற ஒரு process IDல ஓடுது. நம்ப Conatinerர ஏமாத்துறோம் Indirect ha. Internalலா , host machine kernel is used.

Top comments (0)