Description
The inconsistent behavior of -i/-t/-T flags in docker exec(/run) and docker compose exec(/run) is a frustrating cognitive burden.
In at least four cases (no flags when stdin is tty; and when stdin is piped: no flags, -i flag, -T flag) the behavior of docker exec/docker compose exec is inconsistent.
Is the inconsistency desirable for any reason? I think they should be completely consistent.
I haven't fully investigated the differences between docker run/docker compose run but I assume they're about the same.
Steps To Reproduce
> cat docker-compose.yaml
services:
db:
image: postgres:14
container_name: db
environment:
- POSTGRES_PASSWORD=woinekbjaksldf8
> docker compose up -d
[+] Running 1/1
⠿ Container db Started 0.5s
################
# STDIN IS TTY, NO FLAGS
> docker exec db psql -U postgres
# (no output)
> docker compose exec db psql -U postgres
# (goes into interactive terminal mode)
################
# STDIN IS PIPED, NO FLAGS
> echo 'SELECT 1;' | docker exec db psql -U postgres
# (no output)
> echo 'SELECT 1;' | docker compose exec db psql -U postgres
the input device is not a TTY
################
# STDIN IS PIPED, -i flag
> echo 'SELECT 1;' | docker exec -i db psql -U postgres
?column?
----------
1
(1 row)
> echo 'SELECT 1;' | docker compose exec -i db psql -U postgres
the input device is not a TTY
################
# STDIN IS PIPED, -T flag
> echo 'SELECT 1;' | docker exec -T db psql -U postgres
unknown shorthand flag: 'T' in -T
See 'docker exec --help'.
> echo 'SELECT 1;' | docker compose exec -T db psql -U postgres
?column?
----------
1
(1 row)
Compose Version
> docker compose version
Docker Compose version v2.15.1
> docker-compose version
Docker Compose version v2.15.1
Docker Environment
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.10.0)
compose: Docker Compose (Docker Inc., v2.15.1)
dev: Docker Dev Environments (Docker Inc., v0.0.5)
extension: Manages Docker extensions (Docker Inc., v0.2.17)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.23.0)
Server:
Containers: 10
Running: 3
Paused: 0
Stopped: 7
Images: 81
Server Version: 20.10.22
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
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.runtime.v1.linux runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 9ba4b250366a5ddde94bb7c9d1def331423aa323
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
seccomp
Profile: default
cgroupns
Kernel Version: 5.15.49-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 7.674GiB
Name: docker-desktop
ID: ZY3H:2EWQ:JKLX:AMZ3:CX6T:AEF3:CCMR:QMUJ:6TUG:CRR3:5BMJ:FGNT
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
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5000
127.0.0.0/8
Live Restore Enabled: false
Anything else?
No response
Description
The inconsistent behavior of
-i/-t/-Tflags indocker exec(/run) anddocker compose exec(/run) is a frustrating cognitive burden.In at least four cases (no flags when stdin is tty; and when stdin is piped: no flags,
-iflag,-Tflag) the behavior ofdocker exec/docker compose execis inconsistent.Is the inconsistency desirable for any reason? I think they should be completely consistent.
I haven't fully investigated the differences between
docker run/docker compose runbut I assume they're about the same.Steps To Reproduce
Compose Version
Docker Environment
Anything else?
No response