1

I'm trying to migrate from manually invoking docker like this:

docker run -v /tmp/bazel:/data -p 9090:8080 buchgr/bazel-remote-cache --max_size=1300

to using a docker-compose.yml file, but cannot seem to know how to pass the --max_size to the container from it:

version: "3"
services:
  worker:
    image: buchgr/bazel-remote-cache
    deploy:
      mode: replicated
      replicas: 2
      restart_policy:
        condition: on-failure
        delay: 10s
        max_attempts: 3
        window: 120s
    ports:
      - 9090:8080
      - 6060:6060
        #args:
        #- max_size=1300
    volumes:
      - "/bazel_cache:/data"

  visualizer:
    image: dockersamples/visualizer:stable
    ports:
      - 8080:8080
    stop_grace_period: 1m30s
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    deploy:
      placement:
        constraints: [node.role == manager]

What am I missing here? I've tried the args: .. bit but docker complains about it:

$ docker stack deploy -c docker-compose.yml bazel_remote_cache
args Additional property args is not allowed

1 Answer 1

6

Anything you pass after the image name in docker run is interpreted as the "command" part, and you'd pass this in a command: field in docker-compose.yml:

version: "3"
services:
  worker:
    command: --max_size=1300

You can separately override the entrypoint: (equivalent to docker run --entrypoint) if you need to replace that field.

If you control the service, consider also making it possible to set these values via environment variables; this is generally easier to set at the deployment layer than providing command-line arguments. If you can make the default main command be short, specifying command: run_service --max_size=1300 as a complete command is also clearer here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.