Docker Compose

Posted by Rico's Nerd Cluster on June 5, 2024

Environment Variable Reading

Through .env: TODO

Through inline env variables

1
2
3
4
5
6
7
8
9
10
11
12
version: '3.8'
services:
  app:
    image: your-image:latest
    environment:
      - USER_NAME=${USER}
    volumes:
      - /home/${USER}/data:/data
    build:
      context: .
      args:
        USER_NAME: ${USER}
  • we are creating a new environment variable USER_NAME=${USER}.
  • We are mounting /home/${USER}/data (local machine) to /data (docker)