gpt4 book ai didi

docker - 即使日志驱动程序设置为无,运行 docker compose up 也会输出日志

转载 作者:行者123 更新时间:2023-12-04 11:58:26 25 4
gpt4 key购买 nike

我正在使用 docker-compose 为我的应用程序运行测试。我的 docker-compose.yml 文件有三个服务,一个用于 mongodb,一个用于我的应用程序,第三个用于我的测试。我为应用程序和 mongodb 设置了日志记录:驱动程序:“无”,因为我只想查看测试日志。
这以前按预期工作。自从我上次参与这个项目以来,我已将 Mac 上的 docker 桌面升级到版本 3.5.2 (3.5.2.18)。现在,所有容器日志在运行时都会淹没我的终端。我不确定发生了什么变化。

version: '3.1'

services:

mongodb:
image: mongo
expose:
- 27017
logging:
driver: "none"

rsscloud:
build: .
command: node --use_strict app.js
environment:
DOMAIN: rsscloud
PORT: 5337
MONGODB_URI: mongodb://mongodb:27017/rsscloud
NODE_TLS_REJECT_UNAUTHORIZED: 0
expose:
- 5337
depends_on:
- mongodb
logging:
driver: "none"

rsscloud-tests:
build: .
command: dockerize -wait tcp://mongodb:27017 -wait http://rsscloud:5337 -timeout 10s bash -c "npm test"
environment:
APP_URL: http://rsscloud:5337
MONGODB_URI: mongodb://mongodb:27017/rsscloud
MOCK_SERVER_DOMAIN: rsscloud-tests
MOCK_SERVER_PORT: 8002
SECURE_MOCK_SERVER_PORT: 8003
volumes:
- ./xunit:/app/xunit
expose:
- 8002
- 8003
depends_on:
- mongodb
- rsscloud
我跑 docker compose up --build --abort-on-container-exit以下是输出示例:
Attaching to mongodb_1, rsscloud-tests_1, rsscloud_1
rsscloud-tests_1 | 2021/07/27 15:43:58 Waiting for: tcp://mongodb:27017
rsscloud-tests_1 | 2021/07/27 15:43:58 Waiting for: http://rsscloud:5337
rsscloud-tests_1 | 2021/07/27 15:43:58 Connected to tcp://mongodb:27017
mongodb_1 | {"t":{"$date":"2021-07-27T15:43:58.964+00:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.18.0.4:39890","uuid":"d9874a7d-e9c3-4e88-b163-c9b9deb582d1","connectionId":2,"connectionCount":2}}
rsscloud-tests_1 | 2021/07/27 15:43:58 Received 200 from http://rsscloud:5337
rsscloud_1 | [15:43:58.993] GET / 200 577 - ::ffff:172.18.0.4 - 20.885 ms
rsscloud-tests_1 |
rsscloud-tests_1 | > rsscloud-server@2.0.0 test /app
rsscloud-tests_1 | > mocha -R mocha-multi --reporter-options spec=-,xunit=xunit/test-results.xml --timeout 10000
rsscloud-tests_1 |
rsscloud-tests_1 |
rsscloud-tests_1 |
rsscloud-tests_1 | Ping XML-RPC to http-post returning XML
mongodb_1 | {"t":{"$date":"2021-07-27T15:44:00.100+00:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.18.0.4:39892","uuid":"df65fb3a-9913-4075-9671-34d2e9a4d7e8","connectionId":3,"connectionCount":3}}
mongodb_1 | {"t":{"$date":"2021-07-27T15:44:00.105+00:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn3","msg":"client metadata","attr":{"remote":"172.18.0.4:39892","client":"conn3","doc":{"driver":{"name":"nodejs","version":"4.0.1"},"os":{"type":"Linux","name":"linux","architecture":"x64","version":"5.10.25-linuxkit"},"platform":"Node.js v12.22.3, LE (unified)|Node.js v12.22.3, LE (unified)"}}}
rsscloud-tests_1 | → MongoDB 'rsscloud' Database Connected
rsscloud-tests_1 | → Mock server started on port: 8002
rsscloud-tests_1 | → Mock secure server started on port: 8003

最佳答案

这是一个 intentional change with docker compose .您可以将其改回使用 docker-composedocker compose 不同并且可能会提供您预期的先前行为。
或者你可以运行 docker compose up -ddocker compose logs rsscloud-tests但我不确定是否有一种简单的方法可以通过 --abort-on-container-exit 做到这一点因为这可能与 -d 不兼容选项。
我建议您遵循此增强请求并竖起大拇指:https://github.com/docker/compose-cli/issues/1615

关于docker - 即使日志驱动程序设置为无,运行 docker compose up 也会输出日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68548009/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com