compose icon indicating copy to clipboard operation
compose copied to clipboard

[BUG] Keypresses are swallowed when piping `docker compose exec` output to `less`

Open rkfg opened this issue 4 months ago • 2 comments

Description

When running commands like docker compose exec containername mysql... | less you've got to press keys twice (or more) for them to take effect.

Steps To Reproduce

  1. docker compose exec db find / | less (use any running container name instead of db)
  2. try to navigate with arrow keys
  3. only if you manage to get to the end of the output, the keys start working normally

Compose Version

Docker Compose version v2.39.1

Docker Environment

Client: Docker Engine - Community
 Version:    28.3.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.26.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.39.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 13
  Running: 13
  Paused: 0
  Stopped: 0
 Images: 149
 Server Version: 28.3.3
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: local
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 nvidia runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
 runc version: v1.2.5-0-g59923ef
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.15.8-custom+
 Operating System: Debian GNU/Linux 13 (trixie)
 OSType: linux
 Architecture: x86_64
 CPUs: 24
 Total Memory: 125.6GiB
 Name: homecomp
 ID: 351707c3-7887-42ad-af47-d492581b85d5
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

Works fine if I run the same command with just docker exec and use an unscoped container name. This is a repost of issue #11775 (closed as stale) which is a repost of issue #8428 which has been closed without any comments.

Please, exclude it from the stale bot, there's nothing to add and this issue is trivially reproduced. Is there a real need to bump it every month so it doesn't get closed?

rkfg avatar Aug 02 '25 15:08 rkfg

I'm looking into this. Sorry for the inconvenience, we use stale bot as we get many issues reported but never get an update from reported after we ask for more details. Stale bot helps us focus on relevant issues, with the risk we miss a few ones.

ndeloof avatar Nov 10 '25 06:11 ndeloof

AFAICT the root cause for this issue is that docker compose exec runs interactive by default, while docker exec requires an explicit -i. Doing so, you have compose and less fighting to capture your keyboard input, so this weird behavior. You can reproduce this same issue running docker exec --interactive db ... | less.

The "fix" is to run compose command with --interactive=false

ndeloof avatar Nov 10 '25 07:11 ndeloof