compose icon indicating copy to clipboard operation
compose copied to clipboard

`docker compose exec -T` outputs garbage (SOH and NUL) characters

Open gustafc opened this issue 4 years ago • 6 comments

Description of the issue

The docker-compose exec and docker compose exec style invocations generate slightly different output, which I believe to be a bug in the docker compose exec flavour.

Here's the long and short of it, where I run echo without any arguments in a service running Ubuntu:

$ cat docker-compose.yml
services:
  demo:
    image: ubuntu
    entrypoint: sleep 1000000
$ docker compose up --detach
[+] Running 2/2
 ⠿ Network docker-compose-exec-bug_default   Created                                                                                                                                                   3.6s
 ⠿ Container docker-compose-exec-bug_demo_1  Started                                                                                                                                                   2.3s
$ docker-compose exec -T demo echo | od -a
0000000   nl                                                            
0000001
$ docker compose exec -T demo echo | od -a
0000000  soh nul nul nul nul nul nul soh  nl                            
0000011

echo without any arguments should just output a newline (nl) and nothing else. That is exactly what the docker-compose exec style invocation outputs, but docker compose exec outputs a bunch of soh and nul characters before the command output. This happens regardless of which command is invoked (I stumbled upon it when using psql in a Postgres container).

If this is not the place to report docker compose bugs, I humbly apologise and ask for directions where to report this bug :)

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.29.1, build c34c88b2
docker-py version: 5.0.0
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1h  22 Sep 2020

Output of docker version

Client:
 Cloud integration: 1.0.14
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.16.3
 Git commit:        370c289
 Built:             Fri Apr  9 22:46:57 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:44:56 2021
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker-compose config (Make sure to add the relevant -f and other flags)

services:
  demo:
    entrypoint: sleep 1000000
    image: ubuntu
version: '3.9'

Bonus: Output of docker compose config

services:
  demo:
    entrypoint:
    - sleep
    - "1000000"
    image: ubuntu
    networks:
      default: null
networks:
  default:
    name: docker-compose-exec-bug_default

Steps to reproduce the issue

  1. Run docker-compose exec -T any-service-that-has-echo echo | od -a
  2. Run docker compose exec -T any-service-that-has-echo echo | od -a
  3. Compare the results

Observed result

  • docker-compose exec outputs just the nl from echo
  • docker compose exec outputs soh and nul characters before the nl from echo

Expected result

docker compose exec should behave as docker-compose exec does, and just output a newline

Stacktrace / full error message

N/A

Additional information

In my reproduction example above, I use docker compose up. Using docker-compose up makes no difference to the various exec results.

gustafc avatar May 04 '21 09:05 gustafc

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.

stale[bot] avatar Nov 09 '21 20:11 stale[bot]

I'd like to point out that this is still a problem. Btw, more system info:

$ docker compose version
Docker Compose version 2.0.0-beta.1

gustafc avatar Nov 10 '21 10:11 gustafc

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

stale[bot] avatar Nov 10 '21 10:11 stale[bot]

Still an issue on 2.2.3. When -T is used, then the output is malformed:

$ dcmp exec -T db cat /etc/hosts
127.0.0.1	localhost
                         ::1	localhost ip6-localhost ip6-loopback
                                                                    fe00::0	ip6-localnet
                                                                                            ff00::0	ip6-mcastprefix
                                                                                                                       ff02::1	ip6-allnodes
                                                                                                                                            ff02::2	ip6-allrouters
                                                                                                                                                                      192.168.112.2	8cfaac435e41

VS

$  dcmp exec db cat /etc/hosts   
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
ff00::0	ip6-mcastprefix
ff02::1	ip6-allnodes
ff02::2	ip6-allrouters
192.168.112.2	8cfaac435e41

pmav99 avatar Jan 25 '22 19:01 pmav99

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.

stale[bot] avatar Jul 31 '22 02:07 stale[bot]

On 2.6.1 this seems to have been fixed.

pmav99 avatar Jul 31 '22 13:07 pmav99

This issue has been automatically closed because it had not recent activity during the stale period.

stale[bot] avatar Aug 13 '22 12:08 stale[bot]