[Docker] shim error: open /dev/ptmx
-
Since http://forums.docker.com looks a hive of activity, asking here just in case someone else has better google-fu than me, or actually knows what I'm looking at.
I'm sure it's something I'm doing/not doing, rather than a problem with docker itself.
Summary: This error, instead of starting the container. (Alpine is merely a tiny distro to reduce amount of space needed.)
[root@host ~]# docker run -it alpine /bin/sh docker: Error response from daemon: shim error: open /dev/ptmx: no such file or directory.
What I'd expect:
pjh@hpdesktop:~$ docker run -it alpine /bin/sh / # ls bin dev etc home lib media mnt proc root run sbin srv sys tmp usr var / # exit pjh@hpdesktop:~$
Variations on googling that error message have provided me with no useful information whatsoever.
However, what *does* work with any command is:
[root@ccu ~]# docker run alpine ls | column -c180 bin dev etc home lib media mnt proc root run sbin srv sys tmp usr var
Even sh is happy to run. When tickled this way:
[root@ccu ~]# docker run alpine sh --help BusyBox v1.26.2 (2017-06-11 06:38:33 GMT) multi-call binary. Usage: sh [-/+OPTIONS] [-/+o OPT]... [-c 'SCRIPT' [ARG0 [ARGS]] / FILE [ARGS]] Unix shell interpreter
The system this is happening on has been built with buildroot, and while not truly embedded, is booting and running of a 2GB CF card. So it's basically running off
rootfs
with some othertempfs
bits thrown in.This means it needs
export DOCKER_RAMDISK=true
before starting.Kernel:
[root@host ~]# uname -a Linux host 4.11.8 #1 SMP Wed Nov 8 15:52:52 UTC 2017 i686 GNU/Linux
Docker:
[root@host ~]# docker info Containers: 9 Running: 0 Paused: 0 Stopped: 9 Images: 3 Server Version: 17.04.0-ce Storage Driver: overlay2 Backing Filesystem: ramfs Supports d_type: true Native Overlay Diff: false Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: containerd version: 422e31ce907fd9c3833a38d7b8fdd023e5a76e73 runc version: N/A (expected: 9c2d8d184e5da67c95d601382adf14862e4f2228) init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574) Kernel Version: 4.11.8 Operating System: Buildroot 2017.05.1 OSType: linux Architecture: i686 CPUs: 1 Total Memory: 1.903GiB Name: ccu ID: K5AC:SVZP:BFNO:FC4Z:ZFFX:NBA4:S3SI:DNY3:NIZR:3IUQ:NITW:NYMW Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false
Runc
[root@host ~]# runc --version runc version commit: 9c2d8d184e5da67c95d601382adf14862e4f2228 spec: 1.0.0-rc2-dev
Startup log
time="2017-11-13T14:34:37.086817175Z" level=info msg="libcontainerd: new containerd process, pid: 4735" time="2017-11-13T14:34:37.123201967Z" level=warning msg="containerd: low RLIMIT_NOFILE changing to max" current=1024 max=4096 time="2017-11-13T14:34:38.114885547Z" level=info msg="[graphdriver] using prior storage driver: overlay2" time="2017-11-13T14:34:38.140549144Z" level=info msg="Graph migration to content-addressability took 0.00 seconds" time="2017-11-13T14:34:38.141016801Z" level=warning msg="Your kernel does not support cgroup blkio weight" time="2017-11-13T14:34:38.141060662Z" level=warning msg="Your kernel does not support cgroup blkio weight_device" time="2017-11-13T14:34:38.141788687Z" level=info msg="Loading containers: start." time="2017-11-13T14:34:38.752964968Z" level=info msg="Loading containers: done." time="2017-11-13T14:34:38.756510390Z" level=warning msg="Not using native diff for overlay2: failed to set opaque flag on middle layer: operation not supported" time="2017-11-13T14:34:38.764741325Z" level=warning msg="failed to retrieve docker-runc version: unknown output format: runc version commit: 9c2d8d184e5da67c95d601382adf14862e4f2228\nspec: 1.0.0-rc2-dev\n" time="2017-11-13T14:34:38.764852233Z" level=warning msg="failed to retrieve docker-init version" time="2017-11-13T14:34:38.765126011Z" level=info msg="Daemon has completed initialization" time="2017-11-13T14:34:38.765165122Z" level=info msg="Docker daemon" commit=4845c56 graphdriver=overlay2 version=17.04.0-ce time="2017-11-13T14:34:38.877487498Z" level=info msg="API listen on /var/run/docker.sock"
Log from running the first example
time="2017-11-13T16:25:57.295550866Z" level=info msg="No non-localhost DNS nameservers are left in resolv.conf. Using default external servers: [nameserver 8.8.8.8 nameserver 8.8.4.4]" time="2017-11-13T16:25:57.295608975Z" level=info msg="IPv6 enabled; Adding default IPv6 external servers: [nameserver 2001:4860:4860::8888 nameserver 2001:4860:4860::8844]" time="2017-11-13T16:25:57.368015082Z" level=error msg="containerd: start container" error="shim error: open /dev/ptmx: no such file or directory" id=11805d44d129b74b5e11057726d2e263db0674dfd635155ebd9d6ae74d343f06 time="2017-11-13T16:25:57.396213676Z" level=error msg="stream copy error: reading from a closed fifo\ngithub.com/docker/docker/vendor/github.com/tonistiigi/fifo.(*fifo).Read\n\t/data/src/embedded/host4/branches/pjh_main/buildroot/buildroot/output/build/docker-engine-v17.04.0-ce/gopath/src/github.com/docker/docker/vendor/github.com/tonistiigi/fifo/fifo.go:142\nbufio.(*Reader).fill\n\t/data/src/embedded/host4/branches/pjh_main/buildroot/buildroot/output/host/usr/lib/go/src/bufio/bufio.go:97\nbufio.(*Reader).WriteTo\n\t/data/src/embedded/host4/branches/pjh_main/buildroot/buildroot/output/host/usr/lib/go/src/bufio/bufio.go:472\nio.copyBuffer\n\t/data/src/embedded/host4/branches/pjh_main/buildroot/buildroot/output/host/usr/lib/go/src/io/io.go:380\nio.Copy\n\t/data/src/embedded/host4/branches/pjh_main/buildroot/buildroot/output/host/usr/lib/go/src/io/io.go:360\ngithub.com/docker/docker/pkg/pools.Copy\n\t/data/src/embedded/host4/branches/pjh_main/buildroot/buildroot/output/build/docker-engine-v17.04.0-ce/gopath/src/github.com/docker/docker/pkg/pools/pools.go:60\ngithub.com/docker/docker/container/stream.(*Config).CopyToPipe.func1.1\n\t/data/src/embedded/host4/branches/pjh_main/buildroot/buildroot/output/build/docker-engine-v17.04.0-ce/gopath/src/github.com/docker/docker/container/stream/streams.go:121\nruntime.goexit\n\t/data/src/embedded/host4/branches/pjh_main/buildroot/buildroot/output/host/usr/lib/go/src/runtime/asm_386.s:1612" time="2017-11-13T16:25:57.398610377Z" level=error msg="Create container failed with error: shim error: open /dev/ptmx: no such file or directory" time="2017-11-13T16:25:57.486411631Z" level=error msg="Handler for POST /v1.28/containers/11805d44d129b74b5e11057726d2e263db0674dfd635155ebd9d6ae74d343f06/start returned error: shim error: open /dev/ptmx: no such file or directory"
I've spent far too long on this already and am starting to pull what's left of my hair out.
-
Incidentally, it does this on other images as well - the other one (well the first one) I tried was Ubuntu..
[root@host~]# docker run ubuntu ls -l /dev/ptmx /dev/pts lrwxrwxrwx 1 root root 8 Nov 13 16:32 /dev/ptmx -> pts/ptmx /dev/pts: total 0 crw-rw-rw- 1 root root 5, 2 Nov 13 16:32 ptmx
[root@host ~]# docker run -it ubuntu sh docker: Error response from daemon: shim error: open /dev/ptmx: no such file or directory.
-
And in case it's stuff on the host that's the problem I created the soft link here:
[root@host ~]# ls /dev/ptmx -l crw-rw-rw- 1 root tty 5, 2 Nov 13 14:34 /dev/ptmx [root@host ~]# ls -l /dev/pts/ptmx lrwxrwxrwx 1 root root 9 Nov 13 16:34 /dev/pts/ptmx -> /dev/ptmx
-
Shit. I've seen this before but definitely don't remember what the problem was. I'll search through old email archives. I don't think the soft link is all you need for ptmx, though, I think there's a special mount required as pseudo-terminals are created on the fly. All of this is normally handled by a distribution but it looks like you're doing Linux From Scratch to me.
-
Ok, two things that might help you in the future, since you already seem to have solved the problem with a symlink:
- In
docker run -it
,i
means "keep stdin open" andt
means "tell the container that stdin is a tty". If you don't need a tty, just-i
should work. - If you're using
docker run
interactively for a container that isn't going to run a service, add the--rm
option so it doesn't leave the container on disk after it exits.
- In
-
@heterodox said in [Docker] shim error: open /dev/ptmx:
Linux From Scratch
Yup.
@ben_lubar said in [Docker] shim error: open /dev/ptmx:
since you already seem to have solved the problem
Er, no I haven't. Will try the other things though when I get access again.
You both have given me ideas for further research though.
-
@heterodox said in Docker.:
I think there's a special mount required as pseudo-terminals are created on the fly.
@ben_lubar said in Docker.:
- In
docker run -it
,i
means "keep stdin open" andt
means "tell the container that stdin is a tty". If you don't need a tty, just-i
should work.
Think I've found the problem. Cheers guys.
Now - how to fix it....
- In
-
Expected behaviour - Desktop:
pjh@hpdesktop:~$ docker run -it ubuntu bash root@4ef46a7ff151:/# ls -l /dev/pts total 0 crw--w---- 1 root tty 136, 0 Nov 14 12:24 0 crw-rw-rw- 1 root root 5, 2 Nov 14 12:24 ptmx root@4ef46a7ff151:/# ls /proc/1/fd -l total 0 lrwx------ 1 root root 64 Nov 14 12:24 0 -> /dev/pts/0 lrwx------ 1 root root 64 Nov 14 12:24 1 -> /dev/pts/0 lrwx------ 1 root root 64 Nov 14 12:24 2 -> /dev/pts/0 lrwx------ 1 root root 64 Nov 14 12:24 255 -> /dev/pts/0 root@4ef46a7ff151:/# exit
pjh@hpdesktop:~$ docker run -i ubuntu bash ls -l /dev/pts total 0 crw-rw-rw- 1 root root 5, 2 Nov 14 12:24 ptmx ls -l /proc/1/fd total 0 lr-x------ 1 root root 64 Nov 14 12:24 0 -> pipe:[81256183] l-wx------ 1 root root 64 Nov 14 12:24 1 -> pipe:[81256184] l-wx------ 1 root root 64 Nov 14 12:24 2 -> pipe:[81256185] pjh@hpdesktop:~$
LFS system:
[root@lfs ~]# docker run -it ubuntu bash docker: Error response from daemon: shim error: open /dev/ptmx: no such device.
[root@lfs ~]# docker run -i ubuntu bash ls -l /dev/pts total 0 crw-rw-rw- 1 root root 5, 2 Nov 14 12:26 ptmx ls /proc/1/fd -l total 0 lr-x------ 1 root root 64 Nov 14 12:26 0 -> pipe:[36409047] l-wx------ 1 root root 64 Nov 14 12:26 1 -> pipe:[36409048] l-wx------ 1 root root 64 Nov 14 12:26 2 -> pipe:[36409049] [root@lfs ~]#
Stumbled across a vague workaround for something totally different (this, via this) I need to do some more research on, but..
LFS:
[root@ccu ~]# docker run -i ubuntu script /dev/null Script started, file is /dev/null # ls -l /dev/pts ls -l /dev/pts total 0 crw--w---- 1 root tty 136, 0 Nov 14 12:40 0 crw-rw-rw- 1 root root 5, 2 Nov 14 2017 ptmx # ls /proc/$$/fd -l ls /proc/$$/fd -l total 0 lrwx------ 1 root root 64 Nov 14 12:40 0 -> /dev/pts/0 lrwx------ 1 root root 64 Nov 14 12:40 1 -> /dev/pts/0 lrwx------ 1 root root 64 Nov 14 12:40 10 -> /dev/tty lrwx------ 1 root root 64 Nov 14 12:40 2 -> /dev/pts/0 # Script done, file is /dev/null [root@ccu ~]#
However still doesn't do what I'm totally after...
[root@ccu ~]# docker run -di ubuntu script /dev/null af34c875980f32388da32c872e7f7a2253f1335139b933209802604eaa20f105 [root@ccu ~]# docker exec -it af34c875980f32388da32c872e7f7a2253f1335139b933209802604eaa20f105 bash rpc error: code = 2 desc = shim error: open /dev/ptmx: no such device [root@ccu ~]# docker exec -i af34c875980f32388da32c872e7f7a2253f1335139b933209802604eaa20f105 bash ls -l /dev/pts total 0 crw--w---- 1 root tty 136, 0 Nov 14 12:42 0 crw-rw-rw- 1 root root 5, 2 Nov 14 12:42 ptmx ls /proc/$$/fd -l total 0 lr-x------ 1 root root 64 Nov 14 12:43 0 -> pipe:[36894995] l-wx------ 1 root root 64 Nov 14 12:43 1 -> pipe:[36894996] l-wx------ 1 root root 64 Nov 14 12:43 2 -> pipe:[36894997] [root@ccu ~]# [root@ccu ~]# docker exec -i af34c875980f32388da32c872e7f7a2253f1335139b933209802604eaa20f105 script /dev/null Script started, file is /dev/null # ls /proc/$$/fd -l ls /proc/$$/fd -l total 0 lrwx------ 1 root root 64 Nov 14 12:45 0 -> /dev/pts/1 lrwx------ 1 root root 64 Nov 14 12:45 1 -> /dev/pts/1 lrwx------ 1 root root 64 Nov 14 12:45 10 -> /dev/tty lrwx------ 1 root root 64 Nov 14 12:45 2 -> /dev/pts/1 #
-
Ok - final workaround until I get more time to waste on this..
[root@host ~]# docker run --name my_container -di ubuntu script -q -c /bin/bash /dev/null f859e4fa4ff78c0b7fe223ed8e49e2146e450b1b86ae8a544b19a947e994df17 [root@host ~]# docker exec -i my_container env TERM=xterm script -q -c "/bin/bash" /dev/null root@f859e4fa4ff7:/# ls ls bin dev home media opt root sbin sys usr boot etc lib mnt proc run srv tmp var root@f859e4fa4ff7:/# ls /proc/self/fd -l ls /proc/self/fd -l total 0 lrwx------ 1 root root 64 Nov 14 16:26 0 -> /dev/pts/1 lrwx------ 1 root root 64 Nov 14 16:26 1 -> /dev/pts/1 lrwx------ 1 root root 64 Nov 14 16:26 2 -> /dev/pts/1 lr-x------ 1 root root 64 Nov 14 16:26 3 -> /proc/21/fd root@f859e4fa4ff7:/#
Don't like it, but I've wasted too much time on this already.
Meanwhile, over on forums.docker where I asked a meta-question about where I should ask about this problem:
-
I had this same error on a 3.14 kernel.
I fixed it by adding "CONFIG_DEVPTS_MULTIPLE_INSTANCES=y" to the kernel config.
I don't know what kernel version you're using, but maybe this helps.
If you look at https://github.com/moby/moby/blob/master/contrib/check-config.sh, it looks like that option is needed on kernels older than 4.8.
-
@grahn said in [Docker] shim error: open /dev/ptmx:
I had this same error on a 3.14 kernel.
I fixed it by adding "CONFIG_DEVPTS_MULTIPLE_INSTANCES=y" to the kernel config.
Not available as an option in either
kernelconfig
orsystemconfig
I don't know what kernel version you're using, but maybe this helps.
# uname -a Linux ccu 4.11.8 #1 SMP Wed Mar 7 13:37:26 UTC 2018 i686 GNU/Linux
If you look at https://github.com/moby/moby/blob/master/contrib/check-config.sh, it looks like that option is needed on kernels older than 4.8.
That check is apparently already in the build:
# grep DEVPTS buildroot/buildroot/output/build/docker-engine-v17.05.0-ce/contrib/check-config.sh -B5 -A5 # required for bind-mounting /dev/mqueue into containers POSIX_MQUEUE ) check_flags "${flags[@]}" if [ "$kernelMajor" -lt 4 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -lt 8 ]; then check_flags DEVPTS_MULTIPLE_INSTANCES fi echo echo 'Optional Features:'
Cheers anyway.
-
@grahn Welcome to the forums!