for-win icon indicating copy to clipboard operation
for-win copied to clipboard

Docker compose on WSL 2.0 messes with the console

Open gyorokpeter opened this issue 1 year ago • 3 comments

Description

Probably this is due to a new feature introduced in a recent update. When running docker compose, keyboard options appear at the bottom of the screen ("v View in Docker Desktop w Enable Watch"). However, as the containers print out logs, the hotkey display scrolls into the logs and mixes in with the log display, making it harder to read. Furthermore, once the docker compose exits, echo on the terminal is disabled, making it necessary to run stty sane to bring it back to working condition. Possibly the same issue prevents the "Press Ctrl+C again to force" feature to also not work - pressing Ctrl+C for the second time does nothing.

Reproduce

  1. Create the following shell script as run.sh, make sure to give it executable permission:
#!/bin/bash
echo '{"time":"2024-04-25T10:53:24.828z","component":"aaa","level":"DEBUG","message":"aaaaaaaaaaaaaaaaa"}'
echo '{"time":"2024-04-25T10:53:24.830z","component":"aaa","level":"INFO","message":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}'
echo '{"time":"2024-04-25T10:53:24.859z","component":"aaaaaaaaaaaaaaa","level":"INFO","message":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}'
echo '{"time":"2024-04-25T10:53:24.861z","component":"aaaa","level":"INFO","message":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}'
echo '{"time":"2024-04-25T10:53:24.861z","component":"aaaa","level":"INFO","message":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}'
echo 'aa{"time":"2024-04-25T10:53:24.898z","component":"aaaa","level":"INFO","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}'
  1. Create the following docker-compose.yaml:
services:
  target:
    image: rockylinux:9
    command: /app/run.sh
    tty: true
    stdin_open: true
    volumes:
    - .:/app
  1. Run docker compose up

Output:

 ✔ Container 20240425-target-1  Created                                                                          0.0s
Attaching to target-1
target-1  | {"time":"2024-04-25T10:53:24.828z","component":"aaa","level":"DEBUG","message":"aaaaaaaaaaaaaaaaa"}
target-1  | {"time":"2024-04-25T10:53:24.830z","component":"aaa","level":"INFO","message":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}ew in Docker Desktop   w Enable Watch
target-1  | {"time":"2024-04-25T10:53:24.859z","component":"aaaaaaaaaaaaaaa","level":"INFO","message":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}atch
target-1  | {"time":"2024-04-25T10:53:24.861z","component":"aaaa","level":"INFO","message":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}h
target-1  | {"time":"2024-04-25T10:53:24.861z","component":"aaaa","level":"INFO","message":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}   w Enable Watch
target-1  | aa{"time":"2024-04-25T10:53:24.898z","component":"aaaa","level":"INFO","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}ocker Desktop   w Enable Watch
target-1 exited with code 0

Note that the w in `w Enable Watch is inverted (black on white background).

  1. After the container exits, try typing anything on the terminal. Nothing shows up, although the shell recognizes the typed characters. Blindly running the stty sane command fixes it.

Expected behavior

The log display should not be clobbered by the hotkey display. The terminal should return to working after the command exits.

docker version

Client:
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.3
 Git commit:        24.0.5-0ubuntu1~22.04.1
 Built:             Mon Aug 21 19:50:14 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Desktop
 Engine:
  Version:          26.0.0
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       8b79278
  Built:            Wed Mar 20 15:18:01 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    24.0.5
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.13.1-desktop.1
    Path:     /usr/local/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.26.1-desktop.1
    Path:     /usr/local/lib/docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container. (Docker Inc.)
    Version:  0.0.27
    Path:     /usr/local/lib/docker/cli-plugins/docker-debug
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.2
    Path:     /usr/local/lib/docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.23
    Path:     /usr/local/lib/docker/cli-plugins/docker-extension
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.4
    Path:     /usr/local/lib/docker/cli-plugins/docker-feedback
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.1.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.6.3
    Path:     /usr/local/lib/docker/cli-plugins/docker-scout
WARNING: Plugin "/usr/local/lib/docker/cli-plugins/docker-scan" is not valid: failed to fetch metadata: fork/exec /usr/local/lib/docker/cli-plugins/docker-scan: no such file or directory

Server:
 Containers: 3
  Running: 1
  Paused: 0
  Stopped: 2
 Images: 60
 Server Version: 26.0.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
 Kernel Version: 5.15.146.1-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 7.76GiB
 Name: docker-desktop
 ID: 3fe98986-4d53-4edd-84ac-201b330bff5a
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=unix:///var/run/docker-cli.sock
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: daemon is not using the default seccomp profile

Diagnostics ID

72DA057C-EA1B-4F30-9DF7-57EA2CA3C204/20240425110714

Additional Info

No response

gyorokpeter avatar Apr 25 '24 11:04 gyorokpeter

I'm can confirm the exact same issues on Docker 4.29.0 (145265) for Mac (Docker Desktop) in a variety of shell environments, including bash, fish and z-shell running in iTerm2.

In particular, the hotkey hints get inserted / concatenated onto the stdout/stderr output of an open docker compose up process, mess with the force kill (CTRL+C, CTRL+C) functionality and leave artefacts on scrollback.

IMHO, at the very least, it must be possible to hide the hotkey info - even if it were working correctly, it's still needlessly blocking a line of my shell real estate without asking (how rude! 😠)

lyrixderaven avatar Apr 26 '24 09:04 lyrixderaven

Confirming WSL showing console interference after "up"-ing a service that either ends on it's own (a job) or ctrl+c killed... Lost the terminal characters -- typing commands works, but the terminal not showing what is being typed.

kbulis avatar Apr 26 '24 18:04 kbulis

very annoing makes me swear all the time I using docker compose now, slowdown development alot, no way to switch it off!

issue duplicates #14021

zba avatar May 03 '24 02:05 zba

JFTR: Deep in the docker compose docs, I found this description of the COMPOSE_MENU environment variable, which controls the display of this menu: https://docs.docker.com/compose/environment-variables/envvars/#compose_menu

The documentation states that the default for this value is 'off', but on my system, this is clearly not the case. Manually setting this as global environment variable to false hid the menu from all docker compose processes. I have already requested a change to the docs to reflect the new defaults.

lyrixderaven avatar May 06 '24 06:05 lyrixderaven

Hello, @gyorokpeter. In v2.26.1 a fix was proposed. With this new version can this bug still be reproduced?

EDIT: v2.27.0/v2.27.0-desktop.2 is the version with the fix

jhrotko avatar May 08 '24 10:05 jhrotko

@jhrotko Upgrades are locked down and controlled by the company, so it might take some time until this version is available.

gyorokpeter avatar May 08 '24 10:05 gyorokpeter

@gyorokpeter if you are using Docker Desktop with the latest updates, you should have v2.27.0-desktop.2 compose version -- check by running docker compose version which should include the mentioned fix

jhrotko avatar May 08 '24 11:05 jhrotko

I have v2.26.1-desktop.1 now.

gyorokpeter avatar May 08 '24 11:05 gyorokpeter

@gyorokpeter you should have the version with the fix :) could you please try to reproduce to confirm that the fix is working?

jhrotko avatar May 09 '24 08:05 jhrotko

I'm not seeing the extra printouts with this version. However could that be because I managed to completely disable the feature by messing with the settings?

gyorokpeter avatar May 09 '24 09:05 gyorokpeter

to be sure that you have the feature enabled run docker compose up --menu=true. This won't change your local COMPOSE_MENU setting

jhrotko avatar May 09 '24 09:05 jhrotko

Just checked that but unfortunately the issue is still present.

gyorokpeter avatar May 09 '24 09:05 gyorokpeter

Could you try updating your Docker Desktop and check with docker compose version v2.27.0-desktop.2? I tried locally and it should work with this version. Sorry for the confusion on my side :) mixed the versions

jhrotko avatar May 09 '24 10:05 jhrotko

As mentioned above, I have no control over updates as it's a company computer. I will keep checking back if it gets updated.

gyorokpeter avatar May 09 '24 10:05 gyorokpeter

same problem occurs on Windows with the Hyper-V engine in 4.29.0 in Mintty terminal. No such problem when downgrading to 4.28.0.

8ctopus avatar May 10 '24 05:05 8ctopus

@8ctopus The compose version 2.27.0-desktop.2 was included in Docker Desktop version 4.30.0

jhrotko avatar May 10 '24 09:05 jhrotko

@jhrotko Thank you, and 4.30.0 breaks file sync to the container in Hyper-V #14060 :(

8ctopus avatar May 10 '24 11:05 8ctopus

@8ctopus That is unrelated to this issue :(

jhrotko avatar May 10 '24 13:05 jhrotko

The visual issues in the Compose logs have been fixed with the version included in Docker Desktop v4.30+ as well as the binaries on GitHub & apt/yum repos.

[!NOTE] Docker Desktop auto-updates are staged. If you have not been prompted to update yet, use the "Check for Updates" button in settings.

For users who are unable to upgrade right away: you can set COMPOSE_MENU=false in your environment or pass --menu=false on the command-line.

milas avatar May 10 '24 17:05 milas

The navigation menu still shows by default on Windows 11 Docker Desktop 4.30.0 (149282) and Compose v2.27.0-desktop.2 even with "Show CLI hints" disabled, and needs to be overridden with COMPOSE_MENU=false.

DominikSerafin avatar May 14 '24 13:05 DominikSerafin

docker compose up --menu=false works like a charm for me.

jonasmarco avatar Jul 23 '24 14:07 jonasmarco