docker / compose

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

[BUG] Docker compose spams terminal while in progress #11254

Open mlava-sn opened 9 months ago

mlava-sn commented 9 months ago

Description

When running commands like docker compose start, stop, up, down, and maybe others, my terminal gets spammed with lines that are normally just overwritten. I don't know enough to say whether it's just one of these again, but feel free to close this if it's a duplicate:

Steps To Reproduce

Create a new folder with a docker-compose.yml file like so:

services:
  db:
    image: mongo
  nginx:
    image: nginx

Run docker compose up -d. (I chose detached to avoid mixing the log information from nginx mongo with the test results).

image

Compose Version

Docker Compose version v2.21.0

Docker Environment

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

Server:
 Containers: 141
  Running: 0
  Paused: 0
  Stopped: 141
 Images: 173
 Server Version: 24.0.7
 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 logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f
 runc version: v1.1.10-0-g18a0cb0
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 5.15.133.1-microsoft-standard-WSL2
 Operating System: Ubuntu 20.04.6 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.57GiB
 Name: PF17VFZ7
 ID: S265:YF6B:PLEM:62QL:4D4K:B2L5:REVN:UCOJ:BVPC:JCFJ:SLGH:5F4A
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  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

Anything else?

As noted in the kernel version, I am running Ubunti in WSL2 on Windows. Specifically Windows 10 Enterprise edition 22h2 with wsl verion 2.0.9.0. I installed docker and the docker compose plugin from the download.docker.com repo as described in this article.

If I downgrade, 2.17.2 is the earliest version I see listed for me that has the same issue. 2.16.0 does not have this issue.

test > apt list -a docker-compose-plugin
Listing... Done
docker-compose-plugin/focal,now 2.21.0-1~ubuntu.20.04~focal amd64 [installed]
docker-compose-plugin/focal 2.20.2-1~ubuntu.20.04~focal amd64
docker-compose-plugin/focal 2.19.1-1~ubuntu.20.04~focal amd64
docker-compose-plugin/focal 2.18.1-1~ubuntu.20.04~focal amd64
docker-compose-plugin/focal 2.17.3-1~ubuntu.20.04~focal amd64
docker-compose-plugin/focal 2.17.2-1~ubuntu.20.04~focal amd64
docker-compose-plugin/focal 2.16.0-1~ubuntu.20.04~focal amd64
<and more...>
github-actions[bot] commented 1 month 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.

mlava-sn commented 1 month ago

From the issue that mentions this one, it sounds like other people are still experiencing this. But for me, I've swapped computers and I'm no longer getting the spam in Ubuntu 22.04.4 LTS on Windows 11.

stale[bot] commented 1 month ago

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

GibsonSoft commented 3 weeks ago

I just ran into this tonight while running docker compose build and I narrowed it down to the layout of a RUN block in my Dockerfile. I'm loading in a bunch of build dependencies via my docker-compose.yml, which are then called when being loaded via apk.

It seems like the issue in this case is due to having apk add as the first statement of the RUN block. With that as the first line, I'll get the "terminal crawl" where the output doesn't overwrite itself and just spams the console. However, if I move it down just one statement, then the build output appears normal.

docker-compose.yml

services:
  unbound:
    image: gibsonsoft/unbound-full
    pull_policy: never
    build:
      context: .
      args:
        ALPINE_VERSION: 3.20.2
        CORE_BUILD_DEPS: >
          gcc
          libgcc
          make
          musl-dev
          linux-headers
          perl

        OPENSSL_BUILD_DEPS: >
          gnupg

        UNBOUND_BUILD_DEPS: >
          protobuf-c-dev
          expat-dev
          expat-static
          libevent-dev
          libevent-static
          libsodium-dev
          libsodium-static
          nghttp2-dev
          nghttp2-static
          hiredis-dev
          flex
          bison

        RUNTIME_DEPS: >
          drill

        OPENSSL_OPGP_1: EFC0A467D613CB83C7ED6D30D894E2CE8B3D79F5 # OpenSSL OMC
        OPENSSL_OPGP_2: 7953AC1FBC3DC8B3B292393ED5E9E43F7DF9EE8C # Richard Levitte
        OPENSSL_OPGP_3: 8657ABB260F056B1E5190839D9C4D26D0E604491 # Matt Caswell
        OPENSSL_OPGP_4: B7C1C14360F353A36862E4D5231C84CDDCC69C45 # Paul Dale
        OPENSSL_OPGP_5: A21FAB74B0088AA361152586B8EF1A6BA9DA2D5C # Tomas Mraz
        OPENSSL_SHA256: 777cd596284c883375a2a7a11bf5d2786fc5413255efab20c50d6ffe6d020b7e
        OPENSSL_SOURCE: https://www.openssl.org/source/
        OPENSSL_VERSION: 3.3.1

        UNBOUND_SHA256: e7dca7d6b0f81bdfa6fa64ebf1053b5a999a5ae9278a87ef182425067ea14521
        UNBOUND_SOURCE: https://nlnetlabs.nl/downloads/unbound/
        UNBOUND_VERSION: 1.21.0

RUN statement in question

RUN <<EOF
    apk add --no-cache --virtual build-deps ${OPENSSL_BUILD_DEPS}
    GNUPGHOME="$(mktemp -d)"
    export GNUPGHOME
    gpg --no-tty --keyserver keyserver.ubuntu.com --recv-keys \
        "${OPENSSL_OPGP_1}" \
        "${OPENSSL_OPGP_2}" \
        "${OPENSSL_OPGP_3}" \
        "${OPENSSL_OPGP_4}" \
        "${OPENSSL_OPGP_5}"
    gpg --batch --verify openssl.tar.gz.asc openssl.tar.gz
    . . .

This results in the spam: term_spam

However, if we move the following line down so that it isn't the first line:

apk add --no-cache --virtual build-deps ${OPENSSL_BUILD_DEPS}

The RUN block now looks as follows:

RUN <<EOF
    GNUPGHOME="$(mktemp -d)"
    export GNUPGHOME
    apk add --no-cache --virtual build-deps ${OPENSSL_BUILD_DEPS}
    gpg --no-tty --keyserver keyserver.ubuntu.com --recv-keys \
        "${OPENSSL_OPGP_1}" \
        "${OPENSSL_OPGP_2}" \
        "${OPENSSL_OPGP_3}" \
        "${OPENSSL_OPGP_4}" \
        "${OPENSSL_OPGP_5}"
    gpg --batch --verify openssl.tar.gz.asc openssl.tar.gz
    . . .

Yay, the spam is gone! term_happiness