Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container output is cut off when run in a non-interactive shell (e.g. from a Git hook) #9143

Closed
ZimbiX opened this issue Feb 4, 2022 · 6 comments

Comments

@ZimbiX
Copy link

ZimbiX commented Feb 4, 2022

Description

Since Docker Compose version 2.2.3, container output is cut off partially or completely when docker compose run is used within a Git hook. I take it this is something to do with it being non-interactive there.

Steps to reproduce the issue:

mkdir derp
cd derp
git init

cat <<END > docker-compose.yml
version: "3.7"
services:
  dev:
    image: debian
END

cat <<END > .git/hooks/pre-commit
#!/bin/bash

set -Eeuo pipefail

docker compose run --rm dev bash -c '
  echo -e "derp1\nderp1.1";
  echo derp2;
  echo derp3; sleep 0.01;
  echo derp4; sleep 0.1;
  echo derp5; sleep 0.1;
  echo derp6; sleep 0.1;
  echo derp7; sleep 0.1;
  echo derp8; sleep 0.1;
  echo derp9; sleep 0.1;
  echo derp10; sleep 0.1;
'
echo Done
END

chmod +x .git/hooks/pre-commit

git commit --allow-empty -m test

Describe the results you received:

➜ docker compose version
Docker Compose version 2.2.3

➜ git commit --allow-empty -m test
derp1
derp1.1
derp2
derp3
derp4
Done
[master 6147b84] test

Describe the results you expected:

Downgrading the docker-compose package to 2.2.2-1, I get:

➜ docker compose version                         
Docker Compose version 2.2.2

➜ git commit --allow-empty -m test               
derp1
derp1.1
derp2
derp3
derp4
derp5
derp6
derp7
derp8
derp9
derp10
Done
[master 17dd551] test

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker info:

➜ docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.7.1-docker)
  compose: Docker Compose (Docker Inc., 2.2.3)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 7
 Server Version: 20.10.12
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
  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.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1407cab509ff0d96baa4f0eb6ff9980270e6e620.m
 runc version: v1.1.0-0-g067aaf85
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.16.5-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 30.59GiB
 Name: ZimbiX-GreenSync
 ID: ILXE:WN3H:SCDF:DOEP:CFRL:TAKL:7UUQ:Z7XX:6PVS:KDH3:4KVG:DB25
 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
 Default Address Pools:
   Base: 172.80.0.0/16, Size: 24

Edit: This may be a duplicate of #9104

@ZimbiX
Copy link
Author

ZimbiX commented Mar 21, 2022

Still present at the latest commit

➜ PATH=/home/brendan/Projects/docker-compose/bin:$PATH docker-compose version          
Docker Compose version v2.3.3-20-gbe187bae

➜ PATH=/home/brendan/Projects/docker-compose/bin:$PATH git commit --allow-empty -m test
derp1
derp1.1
derp2
derp3
Done
[master 3e08283] test

Edit: I'd been wondering if #9258 might have helped

@EricVogl-carta
Copy link

Can confirm I'm seeing the same behavior using Docker Compose v2.3.3 (via Docker Desktop for MacOS v4.6.1).

@glours
Copy link
Contributor

glours commented Apr 5, 2022

A new release of Docker Desktop is coming soon shipped with the v2.4.1 version of Compose and improvements of run, exec commands and TTY

@ZimbiX
Copy link
Author

ZimbiX commented Apr 7, 2022

On Docker Compose 2.4.1, I instead get:

➜ git commit --allow-empty -m test      
the input device is not a TTY

@EricVogl-carta
Copy link

Can confirm this is still an issue on Docker Compose 2.6.0. Seeing the same as ZimbiX.

ZimbiX added a commit to ZimbiX/dotfiles that referenced this issue Aug 12, 2022
…ns of Docker Compose

This lets me finally upgrade from Docker Compose 2.2.2

Relates to docker/compose#9143
@ZimbiX
Copy link
Author

ZimbiX commented Aug 12, 2022

As a workaround to avoid the the input device is not a TTY error, I've created a docker-compose wrapper to add the now-required --no-TTY option when it detects a lack of TTY (e.g. running from a git hook). With this on Docker Compose 2.9.0, I no longer see my original issue of the output being cut off; I can now finally stay upgraded from Docker Compose 2.2.2, so I'm considering this issue resolved. However, I reckon Docker Compose should be made able to automatically add --no-TTY.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants