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 running containers , NOT RUNNING but exited ]
--> -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 ]
--> 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
- 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 ]
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
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 ]
- 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 :
- head --> It will show the
- Image is also a OS. Image ஓட running instanceதான் Container.
- Container won't have size [ COW ] Copy on write. The Container will refer all from images.
- 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 ).
- Daemon process --> running in the back-ground.
- systemd --> what is "d" here ? No one knows.
- Containerகுள்ள ஓடுற Process ID வந்து நம்ம 1ல தான் start ஆகுது , but அதே process , host machineல , வேற ஒரு process IDல ஓடுது. நம்ப Conatinerர ஏமாத்துறோம் Indirect ha. Internalலா , host machine kernel is used.




Top comments (0)