multi container in a pod and localhost lookup
Apr 11, 2020
- Create a pod with 2 containers
- If you have docker for mac, go inside hyperkit
- screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
- list all processes running ps -ef, find the ones which were started by your pod. In pod spec above the process id are 12913( nginx)and 12981 (the tail commad running in alpine )
- List namespaces for each process id
lsns -t net -o NS,TYPE,PATH,NPROCS,PID,PPID,COMMAND,UID,USER
- notice that processes have same namespace id for net and ipc, they are essentially in same “container” and hence localhost lookup is possible
References
- Linux namespace https://en.wikipedia.org/wiki/Linux_namespaces
- https://en.wikipedia.org/wiki/LXC
- https://www.redhat.com/sysadmin/7-linux-namespaces
- https://lwn.net/Articles/199643/
- https://earthly.dev/blog/lxc-vs-docker/
- What Are Namespaces and cgroups, and How Do They Work? — NGINX
- Kubernetes multi-container pods and container communication| Mirantis