docker compose 版本 v2.20.x 及更早版本中的命令输出docker compose ps
很短,因为“COMMAND”列被截断:
$ sudo apt-get install 'docker-compose-plugin=2.20.*'
[...]
$ docker compose version
Docker Compose version v2.20.2
$ docker compose ps postgres
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
xxxxxxxxx-postgres xxxxxxxxx-postgres:yyyyyyyyyyyyy "docker-entrypoint.s…" postgres 2 weeks ago Up 2 weeks (healthy) 127.0.0.1:9432->5432/tcp
但是从 docker compose 版本 v2.21.x 及更新版本开始,docker compose ps
命令的输出变长,因为“COMMAND”列没有被截断:
$ sudo apt-get install 'docker-compose-plugin=2.21.*'
[...]
$ docker compose version
Docker Compose version v2.21.0
$ docker compose ps postgres
NAME IMAGE COMMAND
SERVICE CREATED STATUS PORTS
xxxxxxxxx-postgres xxxxxxxxx-postgres:yyyyyyyyyyyyy "docker-entrypoint.sh postgres -c tcp_keepalives_idle=600 -c shared_preload_libraries=pg_stat_statements,pg_cron -c cron.database_na
me=nnnnnnnnnn" postgres 2 weeks ago Up 2 weeks (healthy) 127.0.0.1:9432->5432/tcp
这很令人困惑,并且不适合 1920x1080 显示器的控制台窗口。列换行到下一行,并且此输出变得难以阅读。
是否有选项可以强制 docker-compose 使用旧式截断短输出格式?
答案1
截断的短输出格式在版本 v2.24 中重新出现:
$ docker compose version
Docker Compose version v2.20.2
$ docker compose ps postgres
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
xxxxxxxxx-postgres xxxxxxxxx-postgres:yyyyyyyyyyyyy "docker-entrypoint.s…" postgres 10 days ago Up 10 days (healthy) 127.0.0.1:9432->5432/tcp
$ sudo apt-get install 'docker-compose-plugin=2.24.*'
...
$ docker compose version
Docker Compose version v2.24.7
$ docker compose ps postgres
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
xxxxxxxxx-postgres xxxxxxxxx-postgres:yyyyyyyyyyyyy "docker-entrypoint.s…" postgres 10 days ago Up 10 days (healthy) 127.0.0.1:9432->5432/tcp