I have docker-compose files that contain enviroment variables, and these are present in the shell, but when I call the docker-compose up comand, the variables are not present.
Why is this?
I know there are other ways to declare / start containers that are more nix’y, but I want to understand what is going on here.
Thanks!
[john@mb:~/repos/homelab/docker/glances]$ sudo docker-compose up -d
WARN[0000] The "THOR_HOST" variable is not set. Defaulting to a blank string.
WARN[0000] The "THOR_IP" variable is not set. Defaulting to a blank string.
[+] Building 0.0s (0/0) docker:default
[+] Running 1/0
✔ Container glances Running 0.0s
[john@mb:~/repos/homelab/docker/glances]$ sudo echo ${THOR_HOST}
mb
[john@mb:~/repos/homelab/docker/glances]$
configuration.nix
environment.variables = {
THOR_HOST = "mb";
<snip some others>
};
docker-compose.yml
version: '3'
services:
monitoring:
container_name: glances
image: nicolargo/glances:latest-full
restart: always
pid: host
ports:
- 61208:61208
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /mnt/BlackUSB:/mnt/BlackUSB
- /home:/home
environment:
- "GLANCES_OPT=-w"
labels:
- "com.centurylinklabs.watchtower.enable=true"
- homepage.group=${THOR_HOST}
- homepage.name=glances
- homepage.href=http://${THOR_IP}:61208
- homepage.icon=glances.png