Nonyck
Nonyck

Reputation: 682

Docker-compose use env_file variables in the command

I'm trying to set up a docker-file for a selenium grid that is able to change the nodes based on an environment variable.

selenoida:
  image: "aerokube/selenoid:latest"
  container_name: selenoid
  network_mode: bridge
  ports:
    - "0.0.0.0:4444:4444"
  volumes:
    - ".:/etc/selenoid"
    - "./target:/output"
    - "/var/run/docker.sock:/var/run/docker.sock"
    - "./target:/opt/selenoid/video"
  environment:
    - "OVERRIDE_VIDEO_OUTPUT_DIR=$PWD/target"
  env_file:
    - variables.env
  command: ["-limit", "$NODES","-enable-file-upload", "-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video"]

But looks like the command is not able to use variables. I tested with ${NODES}, NODES.

Any ideas on how to use env variables set from a file in commands?

Upvotes: 0

Views: 211

Answers (1)

camba1
camba1

Reputation: 1830

The command in exec form will not invoke the shell to expand the variables.

You can try using the command in shell form, or just overwrite the entrypoint with:

entrypoint: [""sh", "-c", "/usr/bin/selenoid -listen :4444 -conf /etc/selenoid/browsers.json -video-output-dir /opt/selenoid/video/ -enable-file-upload -limit $${NODES}"]

Upvotes: 1

Related Questions