jupyterhub / binderhub

Run your code in the cloud, with technology so advanced, it feels like magic!
https://binderhub.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.54k stars 388 forks source link

Expose build pod name in Docker-in-Docker pod #1788

Open rgaiacs opened 11 months ago

rgaiacs commented 11 months ago

Consider a running instance of BinderHub using Docker-in-Docker. The binderhub-dind pod has the follow processes

PID   USER     TIME  COMMAND
    1 root      0:05 docker-init -- dockerd --storage-driver=overlay2 -H unix:///var/run/dind/docker.sock --mtu=1000
  841 root     14h54 dockerd --storage-driver=overlay2 -H unix:///var/run/dind/docker.sock --mtu=1000
  877 root     28:12 containerd --config /var/run/docker/containerd/containerd.toml
604742 root      0:00 /usr/local/bin/containerd-shim-runc-v2 -namespace moby -id 63eb40b8384d9b3d9667c72c33078c9cdf5dbc4863e909aa96f9431b85051c7b -address /var/run/docker/containerd/containerd.sock
604760 1000      0:00 /bin/sh -c TIMEFORMAT='time: %3R' bash -c 'time ${MAMBA_EXE} env update -p ${NB_PYTHON_PREFIX} --file "environment.yml" && time ${MAMBA_EXE} clean --all -f -y && ${MAMBA_EXE} list -p ${NB_PYTHON_PREFIX} '
604781 1000      0:00 bash -c time ${MAMBA_EXE} env update -p ${NB_PYTHON_PREFIX} --file "environment.yml" && time ${MAMBA_EXE} clean --all -f -y && ${MAMBA_EXE} list -p ${NB_PYTHON_PREFIX}
604782 1000      1:06 {mamba} /srv/conda/bin/python /srv/conda/bin/mamba env update -p /srv/conda/envs/notebook --file environment.yml
604786 1000      0:00 /srv/conda/bin/python -c from multiprocessing.resource_tracker import main;main(6)
604789 root      0:00 sh -c clear; (bash || ash || sh)
604797 root      0:00 ash

How can I tell which build pod is related with the process 604781?

manics commented 11 months ago

I think the processes associated with a container are also present on the host in a cgroups namespace: https://stackoverflow.com/questions/34878808/finding-docker-container-processes-from-host-point-of-view It might be more complicated due to three levels (build-pod - dind - host) instead of two.