【问题标题】:How to suppress warnings in docker-compose?如何抑制 docker-compose 中的警告?
【发布时间】:2020-08-07 12:14:03
【问题描述】:

在开发环境中,将 docker-compose 与为 Docker Swarm 制作的 compose 文件一起使用,例如:

version: "3.8"
services:
  some-service:
    image: nginx
    ports:
      - "8080:80"
    configs:
      - source: some-config
        target: /etc/nginx/nginx.conf
configs:
  some-config:
    external: true

总是有这样的警告:

WARNING: Some services (some-service) use the 'configs' key, which will be ignored. Compose does not support 'configs' configuration - use `docker stack deploy` to deploy to a swarm.

此主文件用于生产,并与其他 compose 文件组合,添加绑定挂载和调试配置,但不知道如何删除“configs”键。

有没有办法通过撰写文件覆盖来抑制此警告或删除“configs”键?

【问题讨论】:

  • 你能分享你的撰写文件吗?

标签: docker docker-compose yaml


【解决方案1】:

configs 键是一个多值选项,不能被覆盖。覆盖文件会将其自己的值连接到现有的值。

参考:https://docs.docker.com/compose/extends/#adding-and-overriding-configuration

我建议将 Swarm 特定密钥保存在单独的专用 docker-compose 文件中,并在需要时将其与其他密钥合并。

【讨论】:

  • 我想避免这种情况。我更喜欢通过使用一个 compose 文件来促进生产部署,然后为不同的开发/调试场景创建多个文件。
猜你喜欢
  • 1970-01-01
  • 2021-06-03
  • 1970-01-01
  • 2019-02-25
  • 2011-03-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多