0

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?

8
  • Use $${NODES} so that Docker does not try to interpret the variable Commented Feb 19, 2021 at 17:17
  • Got the same result, is not getting the value from the variable Commented Feb 19, 2021 at 17:55
  • interesting... I assume the NODES var is defined in variables.env.... This is how I use an environment variable to start ` redis: entrypoint: ["sh", "-c", "redis-server --appendonly yes --requirepass $${REDIS_PASS}"] ` Commented Feb 19, 2021 at 18:05
  • 1
    You are absolutely right, I completely forgot that the command in exec form will not invoke the shell to expand the variables. My bad. You can try using the command in shell form, or just overwrite the entrypoint with something like entrypoint: [""sh", "-c", "/usr/bin/selenoid -listen :4444 -conf /etc/selenoid/browsers.json -video-output-dir /opt/selenoid/video/ -enable-file-upload -limit $${NODES}"] Commented Feb 19, 2021 at 19:30
  • 1
    I looked at their dockerfile in GitHub and that is the path they used there :) Commented Feb 19, 2021 at 21:06

1 Answer 1

1

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}"]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.