0

I have the following docker command:

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

I'm trying to move this into a docker-compose.yml file but I'm having issues with the --config option. My file looks like this, can anyone see where I am going wrong:

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

I've moved the config file accordingly to match. The error message I am getting on sudo docker-compose up is:

collector_1  | Error: Missing option --config
collector_1  | Try --help for more information.
collector_1  | configuration has no "collector" path
Hans
  • 2,800
  • 3
  • 28
  • 40
  • The above error is when you run the `docker-compose up`? – nitishagar Apr 10 '20 at 17:32
  • yes, it is on `sudo docker-compose up`. This is under Ubuntu 18.04 – Hans Apr 10 '20 at 17:36
  • Do you get some `WARNING` similar to this: `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.` – nitishagar Apr 10 '20 at 17:41
  • Yes, but I cannot make sense of how to resolve this. – Hans Apr 10 '20 at 17:43

2 Answers2

4

Everything that appears after an image name is overriding the image default command. So you want:

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

When an image has an entrypoint defined, the command is appended after the entrypoint to become arguments to the command. Using json formatting is important to avoid this being wrapped in a /bin/sh -c "..." syntax.

BMitch
  • 231,797
  • 42
  • 475
  • 450
2

Apparently, the --config with the docker command and configs in docker-compose point two separate things.

The configs option in the compose file is for docker config which is used for setting service config. See more details here. This plays nicely with docker swarm and while running docker services.

On the other hand, the --config option is specifically for the docker client config i.e. the file under .docker directory. More details here.

Note: I can see why this naming is super confusing. There is a warning issued when you run docker-compose up with configs which hints at configs - excerpt below (based on your collector tag):

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.
nitishagar
  • 9,038
  • 3
  • 28
  • 40