cli icon indicating copy to clipboard operation
cli copied to clipboard

Some exec errors are output to stdout instead of stderr

Open tfsJoe opened this issue 5 months ago • 0 comments

Description

I have noticed that I am unable to suppress at least some errors from docker exec by appending 2> /dev/null. However, I was able to suppress them with 1> /dev/null - although this is less useful. This leads me to believe that the errors are being placed into the standard output stream rather than the error stream. Example:

docker exec -it zwave-js-ui /bin/bash 2> /dev/null
OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown

Reproduce

  1. Add the container zwave-js-ui. I did this using docker-compose.yml. image: zwavejs/zwave-js-ui:latest. I chose this container because it does not include /bin/bash, but any container without /bin/bash will do. Alternatively, you can run a different nonexistent command on step 3 on any container.
  2. Run docker-compose up or otherwise ensure the container is started.
  3. Run the following command: docker exec -it zwave-js-ui /bin/bash 2> /dev/null

Observe that the error will not be suppressed:

$ docker exec -it zwave-js-ui /bin/bash 2> /dev/null
OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown

Alternative step 3: Run docker exec -it zwave-js-ui /bin/bash 1> /dev/null. Observe that the error is now suppressed.

Expected behavior

  1. Appending 2> /dev/null to a docker exec command should not output anything if an error occurs.
  2. Appending 1> /dev/null to a docker exec command should not suppress errors.

docker version

Version:           20.10.5+dfsg1
 API version:       1.41
 Go version:        go1.15.15
 Git commit:        55c4c88
 Built:             Mon May 30 18:34:49 2022
 OS/Arch:           linux/arm
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.5+dfsg1
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.15.15
  Git commit:       363e9a8
  Built:            Mon May 30 18:34:49 2022
  OS/Arch:          linux/arm
  Experimental:     false
 containerd:
  Version:          1.4.13~ds1
  GitCommit:        1.4.13~ds1-1~deb11u4
 runc:
  Version:          1.0.0~rc93+ds1
  GitCommit:        1.0.0~rc93+ds1-5+deb11u2
 docker-init:
  Version:          0.19.0
  GitCommit:

docker info

Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 4
  Running: 4
  Paused: 0
  Stopped: 0
 Images: 6
 Server Version: 20.10.5+dfsg1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1.4.13~ds1-1~deb11u4
 runc version: 1.0.0~rc93+ds1-5+deb11u2
 init version: 
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 6.1.21-v7+
 Operating System: Raspbian GNU/Linux 11 (bullseye)
 OSType: linux
 Architecture: armv7l
 CPUs: 4
 Total Memory: 922MiB
 Name: pi
 ID: UPTV:EM7Y:LQGK:LYGD:XSSM:M52D:S4EM:UI5I:26CB:3Y2V:ZW56:ETLY
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  https://mirror.gcr.io/
 Live Restore Enabled: false

WARNING: No memory limit support
WARNING: No swap limit support
WARNING: Support for cgroup v2 is experimental

Additional Info

Running on a Raspberry Pi.

tfsJoe avatar Feb 03 '24 05:02 tfsJoe