docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.72k stars 5.19k forks source link

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

Open rkfg opened 5 months ago

rkfg commented 5 months ago

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.26.1

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc., v2.26.1)

Server:
 Containers: 71
  Running: 17
  Paused: 0
  Stopped: 54
 Images: 61
 Server Version: 20.10.24+dfsg1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 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.6.20~ds1-1+b1
 runc version: 1.1.5+ds1-1+deb12u1
 init version: 
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 6.1.0-20-amd64
 Operating System: Debian GNU/Linux 12 (bookworm)
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 15.39GiB
 Name: hostname
 ID: NHM3:FVMR:7XMQ:C4PM:75GM:VOLR:XVHB:VLRE:DJCY:E3HT:YNXH:AV65
 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
 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 #8428 which has been closed without any comments.

x-yuri commented 5 months ago

If you want to pipe docker exec into a pager, then you probably want to add -T:

docker compose exec -T db find / | less

If that doesn't work:

docker compose exec -T db find / </dev/null | less

The latter looks like a workaround that should not be needed.

rkfg commented 5 months ago

-T doesn't change anything for me but </dev/null does (i.e. it works as expected with it)! It feels like compose and the pager fight for stdin which causes these skips.

github-actions[bot] commented 3 days ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

rkfg commented 3 days ago

Still an issue in compose v2.29.7

stale[bot] commented 3 days ago

This issue has been automatically marked as not stale anymore due to the recent activity.