Database Environment Variables not available with systemd unit start



I have my package-based docker container based on the univention/ucs-appbox-amd64:4.2-2 image up and running. My app is started - as suggested - via a systemd service unit.

The app fails to start up, because it is missing the environment variables (DB_HOST, DB_PASSWORD, DB_NAME and so on) to connect to the host’s mysql database. I’ve dump a list of the environment during the application’s startup:

Mar 06 15:27:30 kitom-23801244 bash[8569]: environ({‘PATH’: ‘/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin’, ‘LANG’: ‘C.UTF-8’, ‘KITOMA_CONFIG’: ‘/opt/kitoma/config/’, ‘FLASK_APP’: ‘kitoma’, ‘_’: ‘/opt/kitoma/bin/python3.4’, ‘PWD’: ‘/opt/kitoma’, ‘KITOMA_MODE’: ‘WEB’, ‘SHLVL’: ‘1’, ‘PYTHONPATH’: ‘/opt/kitoma/’})

The set variables are configured in the systemd unit:

Description=Kitoma VOIP-Management

ExecStart=/opt/kitoma/bin/python3.4 -m flask run --host


Please note that the required environment variables are available when I run the application manually from the bash console. I also tried to set ExecStart to start with

/bin/bash -c "myapp"

but it did not change the behavior. At the moment I have no idea how to make sure that the environment variables are injected into the systemd unit’s context.



maybe it is possible to use EnvironmentFile? You could write it manually in a custom setup file (that calls the original setup script at the end).

Dirk Wiesenthal


Thanks this works. After some more investigation systemd does not embed the enviornment variables at all as it runs in a very own context.

I create my environment file now in the join script and this works fine.