Repository navigation
docker-compose CLI output is not "greppable" any more #9202
Copy link
Copy link
Closed
Labels
Description
- I have tried with the latest version of Docker Desktop
- I have tried disabling enabled experimental features
- I have uploaded Diagnostics
- Diagnostics ID: F422FCD1-9103-499F-B66B-A21B08AF9789/20220218084251
Expected behavior
CLI output from docker-compose is "greppable".
Actual behavior
CLI output from docker-compose is not "greppable". But CLI output from docker command is "greppable".
Information
- Problem is reproducible
- Problem was noticed yesterday afternoon. Yesterday evening Docker Desktoop was updated, problem persists
- Problem appeared with an update, but I don't know since when it exists
- macOS Version: Big Sur 11.6.2
- Intel chip: 2,7 GHz Quad-Core Intel Core i7
- Docker Desktop Version: 4.5.0 (74594)
Output of /Applications/Docker.app/Contents/MacOS/com.docker.diagnose check
$ /Applications/Docker.app/Contents/MacOS/com.docker.diagnose check
Starting diagnostics
[PASS] DD0027: is there available disk space on the host?
[PASS] DD0028: is there available VM disk space?
[PASS] DD0031: does the Docker API work?
[PASS] DD0004: is the Docker engine running?
[PASS] DD0011: are the LinuxKit services running?
[PASS] DD0016: is the LinuxKit VM running?
[PASS] DD0001: is the application running?
[PASS] DD0018: does the host support virtualization?
[PASS] DD0017: can a VM be started?
[PASS] DD0015: are the binary symlinks installed?
[PASS] DD0003: is the Docker CLI working?
[PASS] DD0013: is the $PATH ok?
[PASS] DD0007: is the backend responding?
[PASS] DD0014: are the backend processes running?
[PASS] DD0008: is the native API responding?
[PASS] DD0009: is the vpnkit API responding?
[PASS] DD0010: is the Docker API proxy responding?
[PASS] DD0012: is the VM networking working?
[PASS] DD0032: do Docker networks overlap with host IPs?
[SKIP] DD0030: is the image access management authorized?
[PASS] DD0019: is the com.docker.vmnetd process responding?
[PASS] DD0033: does the host have Internet access?
No fatal errors detected.
Steps to reproduce the behavior
$ cat docker-compose.yml
services:
web:
image: nginx
$ docker-compose up -d
[+] Running 1/1
⠿ Container tmp-web-1 Started
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2904a5bfd2ed nginx "/docker-entrypoint.…" 49 seconds ago Up 49 seconds 80/tcp tmp-web-1
$ docker exec 2904a5bfd2ed ls -lh
total 80K
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 bin
drwxr-xr-x 2 root root 4.0K Dec 11 17:25 boot
drwxr-xr-x 5 root root 340 Feb 18 08:36 dev
drwxr-xr-x 1 root root 4.0K Jan 26 08:58 docker-entrypoint.d
-rwxrwxr-x 1 root root 1.2K Jan 26 08:58 docker-entrypoint.sh
drwxr-xr-x 1 root root 4.0K Feb 18 08:36 etc
drwxr-xr-x 2 root root 4.0K Dec 11 17:25 home
drwxr-xr-x 1 root root 4.0K Jan 25 00:00 lib
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 lib64
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 media
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 mnt
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 opt
dr-xr-xr-x 199 root root 0 Feb 18 08:36 proc
drwx------ 2 root root 4.0K Jan 25 00:00 root
drwxr-xr-x 1 root root 4.0K Feb 18 08:36 run
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 sbin
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 srv
dr-xr-xr-x 13 root root 0 Feb 18 08:36 sys
drwxrwxrwt 1 root root 4.0K Jan 26 08:58 tmp
drwxr-xr-x 1 root root 4.0K Jan 25 00:00 usr
drwxr-xr-x 1 root root 4.0K Jan 25 00:00 var
$ docker exec 2904a5bfd2ed ls -lh | grep boot ######### <- This work's.
drwxr-xr-x 2 root root 4.0K Dec 11 17:25 boot
$ docker-compose exec web ls -lh
total 80K
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 bin
drwxr-xr-x 2 root root 4.0K Dec 11 17:25 boot
drwxr-xr-x 5 root root 340 Feb 18 08:36 dev
drwxr-xr-x 1 root root 4.0K Jan 26 08:58 docker-entrypoint.d
-rwxrwxr-x 1 root root 1.2K Jan 26 08:58 docker-entrypoint.sh
drwxr-xr-x 1 root root 4.0K Feb 18 08:36 etc
drwxr-xr-x 2 root root 4.0K Dec 11 17:25 home
drwxr-xr-x 1 root root 4.0K Jan 25 00:00 lib
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 lib64
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 media
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 mnt
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 opt
dr-xr-xr-x 199 root root 0 Feb 18 08:36 proc
drwx------ 2 root root 4.0K Jan 25 00:00 root
drwxr-xr-x 1 root root 4.0K Feb 18 08:36 run
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 sbin
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 srv
dr-xr-xr-x 13 root root 0 Feb 18 08:36 sys
drwxrwxrwt 1 root root 4.0K Jan 26 08:58 tmp
drwxr-xr-x 1 root root 4.0K Jan 25 00:00 usr
drwxr-xr-x 1 root root 4.0K Jan 25 00:00 var
$ docker-compose exec web ls -lh | grep boot ######### -> This doesn't work.
total 80K
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 bin
drwxr-xr-x 2 root root 4.0K Dec 11 17:25 boot
drwxr-xr-x 5 root root 340 Feb 18 08:36 dev
drwxr-xr-x 1 root root 4.0K Jan 26 08:58 docker-entrypoint.d
-rwxrwxr-x 1 root root 1.2K Jan 26 08:58 docker-entrypoint.sh
drwxr-xr-x 1 root root 4.0K Feb 18 08:36 etc
drwxr-xr-x 2 root root 4.0K Dec 11 17:25 home
drwxr-xr-x 1 root root 4.0K Jan 25 00:00 lib
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 lib64
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 media
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 mnt
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 opt
dr-xr-xr-x 199 root root 0 Feb 18 08:36 proc
drwx------ 2 root root 4.0K Jan 25 00:00 root
drwxr-xr-x 1 root root 4.0K Feb 18 08:36 run
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 sbin
drwxr-xr-x 2 root root 4.0K Jan 25 00:00 srv
dr-xr-xr-x 13 root root 0 Feb 18 08:36 sys
drwxrwxrwt 1 root root 4.0K Jan 26 08:58 tmp
drwxr-xr-x 1 root root 4.0K Jan 25 00:00 usr
drwxr-xr-x 1 root root 4.0K Jan 25 00:00 var
Reactions are currently unavailable
Activity
glours commentedon Feb 24, 2022
Can you share the output of the following command
docker infoplease?ndeloof commentedon Feb 24, 2022
Can you please clarify what you expect compose output to look like so it is "greppable"?
I.e what's the command you'd like to type that would include use of
grep?ndeloof commentedon Feb 24, 2022
eventually understood the issue during a chat session with @glours :)
so, basically, before 2.2.3 we had code to detect current process is running or not within a TTY, and then adjust the way we interact with stdin/stdout. This had some complex side effects for users who want to redirect some stream to stdin, etc.
In 2.2.3 we made this user responsibility to disable TTY (
--no-tty) when they want to rely on POSIX streams, typically to pipe output to another command. This is the issue you have here.A long term solution is for us to share more code with docker/cli, so that we don't need to reinvent the wheel and suffer from issues that
dockercommand line already addressed. see docker/cli#3436thaJeztah commentedon Feb 25, 2022
Yes, it's a bit unfortunate that the defaults (for TTY (
-t/--tty) are "flipped" (compose enables it by default); while there's things to say for both approaches (compose focusses more on interactively running things, whereas the docker engine / cli considers that "opt-in"), it makes things somewhat inconsistent (and sometimes quite "subtle").Curious now; what's the default on compose for attaching
stdin(-i,--interactive) ? I guess default is "enabled" as well?I actually recalled I wanted to write a proposal that's slightly related, and just did: #9207
niftyhack commentedon Feb 25, 2022
@glours
niftyhack commentedon Feb 25, 2022
Well, using the docker-compose.yml from the provided example ...
... greps the output from the docker command for
bootand displays the lines containingboot.However:
does not seem to grep correctly. The output I get is the whole output from the
ls -lhcommand from within the container.thaJeztah commentedon Feb 25, 2022
@niftyhack and it does work when adding the
-Toption to thedocker compose exec?niftyhack commentedon Feb 28, 2022
@thaJeztah
Somehow, but the output is mangled:
~/tmp/docker-composeis part of my prompt, which display the current working directory on an extra line.You can see it better if you pass
--helpas an option forlsin the container and grep the output ofls --help:The output is also mangled if I just do
docker-compose exec -T web ls --help, but somehow I can't paste the whole output to Github. On the other hand, piping the output to vim is fine,docker-compose exec -T web ls --help | vim -displaysls --helpnicely formatted in a vim buffer.I also noticed that
docker-compose helpdoes not mention the-Toption.chuck-confluent commentedon Apr 7, 2022
This broke a demo of mine so it either works for users with the latest version of docker-compose, or users with older versions, but not both. Let me give an example.
Me, with a newer version of docker compose (2.2.3):
gives output
RUNNINGFriend, running the same command with an older version (1.29) of docker-compose gives blank output.
Conversely, friend runs without
--no-TTY:Whereas I get blank output.
glours commentedon Apr 7, 2022
@chuck-confluent which version of Docker Compose are you using? Can you give a try to the
v2.4.1version and let us now if it's work as expected please?chuck-confluent commentedon Apr 7, 2022
I'm using version 2.2.3, which comes with gitpod. My friend couldn't give me a version, but hers is older.
niftyhack commentedon Apr 8, 2022
FYI I just upgraded to Docker Desktop for Mac Version 4.6.1 (76265) and macOs Monterey 12.3.1 (21E258) on Apple Silicon (M1) and the problem went away.
Edit:
jdreesen commentedon May 10, 2022
It works for me with Docker Compose
v2.5.0stale commentedon Jan 7, 2023
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.