This is my compose.yaml
, and i don’t have any .env
in my working dir.
services:
service_a:
image: "my_img"
environment:
- WORKER_NUMBER=1
stdin_open: true
tty: true
command: >
bash -c "export PATH=/root/miniconda3/bin:$PATH
&& conda init
&& echo "WORKER_NUMBER=${WORKER_NUMBER}
&& tail -f /dev/null"
When i use docker compose up
i get a warning:
WARN[0000] The "WORKER_NUMBER" variable is not set. Defaulting to a blank string.
And the print result is
WORKER_NUMBER=
Why and how to set env var by environment
attribute correctly? Thanks for any helps!
My Docker & Docker compose ver:
Server: Docker Engine - Community
Engine:
Version: 19.03.15
Docker Compose version v2.27.0