Use docker environment variables instead of tagem-auth.cfg file
Can you make the targets in the .cfg file environment variables like shown in the config file below? It seems many other containers use the format below to pass login info to a database instance and it works pretty slick. Maybe an either or thing for those that aren't using compose and would rather use a local file.
tagem:
image: notcompsky/tagem:latest
container_name: tagem
restart: always
networks:
- proxy
- tagem
volumes:
- /etc/localtime:/etc/localtime:ro
security_opt:
- no-new-privileges:true
ports:
- "$TAGEM_PORT:80"
environment:
MYSQL_HOSTNAME: tagemdb
MYSQL_PORT: $DB_PORT
MYSQL_DATABASE: db
MYSQL_USER: tagem
MYSQL_PASSWORD: $USER_PASS
depends_on:
- tagemdb
I've never used Docker Compose or LinuxServer so I'm not sure I understand what you're asking.
But this compose file will fail to run because the cfg file is being loaded onto the container in the root directory, while the environmental variable TAGEM_MYSQL_CFG - which should point to that cfg file - instead points to the location of the cfg file on the server, rather than the location it is mapped to on the container.
Do you want that environmental variable to be set by default? Again sorry for not understanding the question, that's just my lack of knowledge, I'm still happy to fix the issue if you see a problem.
My thought was that environment variables could be used instead of the tagem-auth.cfg file. That way the file doesn't need to exist and the relevant information can be passed to the container during creation.
This is how the database would be set up in the compose file, you can see how the environment variables match up to the environment variables in the example I posted above.
tagemdb:
image: linuxserver/mariadb:latest
container_name: tagemdb
hostname: tagemdb
restart: always
networks:
- tagem
security_opt:
- no-new-privileges:true
volumes:
- $CONFIG_DIR/tagem/db:/config
- /etc/localtime:/etc/localtime:ro
environment:
PUID: $PUID
PGID: $PGID
MYSQL_ROOT_PASSWORD: $ROOT_PASS
MYSQL_DATABASE: db
MYSQL_USER: tagem
MYSQL_PASSWORD: $USER_PASS
MYSQL_ROOT_HOST: "%"
My thought was that environment variables could be used instead of the tagem-auth.cfg file. That way the file doesn't need to exist and the relevant information can be passed to the container during creation.
Thanks for the title change, it's a lot clearer now.
Your request is reasonable, and I will try to implement it. It should be fairly simple to do.
The question I have though is whether it would be as easy to have them as command-line arguments rather than environmental variables?
You can also set environment variables in the command line, you don't need to use compose. This way also gives the option of an environment file, so you could still have an option of using a file like you have currently, it would just need to be formatted differently.
https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file