我有以下停靠命令:
sudo docker run --env-file env.list \
-p 80:8080 \
-v $PWD/snowplow/config:/snowplow/config \
snowplow/scala-stream-collector-kinesis:1.0.0 \
--config /snowplow/config/config.hocon我试图将它移到一个docker-compose.yml文件中,但是-config选项有问题。我的档案是这样的,有人能看到我哪里出错了吗?
version: '3.3'
services:
collector:
image: snowplow/scala-stream-collector-kinesis:1.0.0
environment:
- AWS_CBOR_DISABLE=1
ports:
- "80:8080"
volumes:
- ./data/snowplow:/snowplow
configs:
- source: collectorcnf
target: /snowplow/config/config.hocon
configs:
collectorcnf:
file: ./data/snowplow/config/config.hocon我已经相应地将配置文件移动到匹配。我在sudo docker-compose up上得到的错误消息是:
collector_1 | Error: Missing option --config
collector_1 | Try --help for more information.
collector_1 | configuration has no "collector" path发布于 2020-04-10 17:50:26
在图像名称之后出现的所有内容都将覆盖图像默认命令。所以你想:
version: '3.3'
services:
collector:
image: snowplow/scala-stream-collector-kinesis:1.0.0
# the below "command" is the portion after the image name in the run command:
command: ["--config", "/snowplow/config/config.hocon"]
environment:
- AWS_CBOR_DISABLE=1
ports:
- "80:8080"
volumes:
- ./data/snowplow:/snowplow当图像定义了一个入口点时,命令就会被追加到入口点之后,从而成为命令的参数。使用json格式对于避免将其包装在/bin/sh -c "..."语法中很重要。
发布于 2020-04-10 17:48:22
显然,带有docker命令的docker和docker-compose中的configs分别指出了两点。
撰写文件中的configs选项用于docker config,用于设置服务配置。请参阅更多细节这里。这对docker swarm和运行docker服务都有很好的效果。
另一方面,--config选项专门用于码头客户端配置,即.docker目录下的文件。更多细节这里。
注意:,我能理解为什么这个命名非常令人困惑。当您使用docker-compose up运行configs时,会发出一个警告,提示下面的configs --摘录(基于您的collector标记):
WARNING: Some services (collector) use the 'configs' key, which will be ignored. Compose does not support 'configs' configuration - use `docker stack deploy` to deploy to a swarm.https://stackoverflow.com/questions/61145433
复制相似问题