--pid=container:<id> does not reparent zombies to pid 1 #25348
Open
Description
opened on Aug 2, 2016
Trying to use shared PID namespaces, we observe that zombie processes are not being reparented to pid 1.
From a simple docker run
it works.
# docker run -ti busybox sh
/ #
/ # echo $$
1
/ # grep PPid /proc/1/status
PPid: 0
/ # sh -c 'echo shell 1 is $$; grep PPid /proc/$$/status; sh -c "echo shell 2 is \$\$; grep PPid /proc/\$\$/status; sleep 9376 & echo \$\$ exiting"; echo $$ exiting'
shell 1 is 6
PPid: 1
shell 2 is 8
PPid: 6
8 exiting
6 exiting
/ # ps auxw | grep 9376
10 root 0:00 sleep 9376
12 root 0:00 grep 9376
/ # grep PPid /proc/10/status
PPid: 1
This is a pretty clear success. If I do this same experiment from a container that joins another PID ns, though:
# docker run -d busybox sleep 10000
c641a5e7eb6839719113dcfaeb80bd3b257b4f159553a85638b826134941787f
# docker run -ti --pid container:c641a5e7e busybox sh
/ #
/ # echo $$
5
/ # grep PPid /proc/1/status
PPid: 0
/ # sh -c 'echo shell 1 is $$; grep PPid /proc/$$/status; sh -c "echo shell 2 is \$\$; grep PPid /proc/\$\$/status; sleep 9376 & echo \$\$ exiting"; echo $$ exiting'
shell 1 is 10
PPid: 5
shell 2 is 12
PPid: 10
12 exiting
10 exiting
/ # ps auxw | grep 9376
14 root 0:00 sleep 9376
16 root 0:00 grep 9376
/ # grep PPid /proc/14/status
PPid: 0
This means that any such container is not managed by the in-container init, but by the host's init. Is this intentional or a bug?
Output of docker version
:
# docker version
Client:
Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e
Built: Thu Jul 28 22:11:10 2016
OS/Arch: linux/amd64
Server:
Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e
Built: Thu Jul 28 22:11:10 2016
OS/Arch: linux/amd64
Output of docker info
:
# docker info
Containers: 4
Running: 2
Paused: 0
Stopped: 2
Images: 1
Server Version: 1.12.0
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 9
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.4.0-31-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 3.613 GiB
Name: docker-current
ID: K6EC:G3VW:TPJ2:VHLT:3HBA:YEKW:PNYV:5Z5X:WJF4:EWSD:FC7B:SOBW
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Insecure Registries:
127.0.0.0/8
Activity