docker / docker/cli

Some exec errors are output to stdout instead of stderr

Open
#4,847 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug status/0-triage
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the docker exec command with a nonexistent command or a container without /bin/bash, then trace the Docker CLI's exec entry point and its stdout/stderr handling. Done means exec errors are suppressed by 2> /dev/null but remain visible when only stdout is redirected.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.