Environmental variables table

  • Hi, I am trying to create an environmental variables table that all my dockers can reference.

    I am looking at this guide: Setting Up Environmental Variables for Docker and Docker Compose

    I am confused on OMV were to put the .env file. Any ideas?

  • The way I read it the file goes into the folder you have set in OMV-Extras | Docker | Docker Storage.


    Note, the URL in your post is broken. I used this one:


    Code
    https://www.smarthomebeginner.com/traefik-2-docker-tutorial/#Docker_Setup

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 5.x on ASRock Rack C2550D4I C0 Stepping - 16GB ECC - Silverstone DS380 + Silverstone DS380 DAS Box.

  • There’s two different environmental variables in discussion here.


    First in yaml the environment keywords generates the lists all ev for the running container.


    Second the .env file is loaded previous reading of the compose yaml and sources all variables that are going to be rendered in the yaml file. Those are the dollar sign variables in the compose file. Those variables are not passed to the container. As mentioned before the .env file goes along the compose file in the same folder.


    So for example in your running container if you exec bash into it and run echo $MEDIA nothing will output as that was a variable used to construct the yaml file.

  • So my question is more, how do we point the container to the .env file? How do we declare the .env? So that the container uses those values.

  • I almost exclusively use the command line. But in this case the files (docker-compose.yml and .env) can be created with notepad++ and then you only need to run docker-compose up -d in the CLI.

    Just to try it out, I just ran a test container:


    I have a folder where all my docker-compose files are stored. In this case both are here: /srv/dev-disk-by-label-ssd/users/docker/docker-compose/nginx/

    Code: .env
    TZ=Europe/Berlin
    PUID=1000
    PGID=100
    BASEDIR=/srv/dev-disk-by-label-ssd/appdata/nginx/
    HTTP_PORT=8082
    HTTPS_PORT=4444

    then just in /srv/dev-disk-by-label-ssd/users/docker/docker-compose/nginx/ I run docker-compose up -d.

    docker inspect nginx:

  • So my question is more, how do we point the container to the .env file? How do we declare the .env? So that the container uses those values.

    You can use a mount bind to pass the whole folder to the container that has the .env but what’s the point? The container will not read that file automatically. The .env file is used to store values that are you going to keep repeating inside the yaml file. A compose file can have many different containers, if each of them need access to a common path or using same PUID .env saves the tedious work of changing every string, instead is just changed at .env just once.

  • Inspired by this thread I continued a project, which I had on my list for some time now. I wanted to put all my docker containers into a single docker-compose file. Just for inspiration these are my docker-compose.yml and my .env. All I need to do is run a docker-compose up -d in the folder containing both files.


    Code: .env
    UID=1000
    GID=100
    TZ=Europe/Berlin
    APPDIR=/srv/dev-disk-by-label-ssd/appdata
    BACKUPDIR=/srv/dev-disk-by-label-ssd/backup
    SYNCDIR=/srv/dev-disk-by-label-ssd/sync
    RESTART=unless-stopped
  • Inspired by this thread I continued a project, which I had on my list for some time now. I wanted to put all my docker containers into a single docker-compose file. Just for inspiration these are my docker-compose.yml and my .env. All I need to do is run a docker-compose up -d in the folder containing both files.

    Yes, a man after my own heart. This is also on my list. I was hoping to do this in Portainer, but I will be doing this in compose also. So you put the two files in one folder? Which folder did you put it in, just out of curiosity? User folder or in a share?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!