KardanovIR
KardanovIR

Reputation: 492

Get all Docker env variables in python script inside a container

I have docker image with bash and python scripts inside it: 1) entrypoint.sh (this script runs python file); 2) parser.py

When developers run a container, they can pass env variables with prefix like MYPREFIX_*.

docker run name -e MYPREFIX_1=true -e MYPREFIX_DEMO=100 ...

There are more than 100 possible keys, they change from time to time (depending on remote configuration file).

I'd like to pass all variables to the bash script and then to the python script.

I can't define all variables inside Dockerfile (keys can change). I also can't use env_file.

Are there any suggestions?

Content of entrypoint:

/usr/bin/python3 "/var/hocon-parser.py"
/usr/bin/curl -sLo /var/waves.jar "https://github.com/wavesplatform/Waves/releases/download/v$WAVES_VERSION/waves-all-$WAVES_VERSION.jar"
/usr/bin/java -jar /var/waves.jar /waves-config.conf

Upvotes: 1

Views: 2720

Answers (1)

KardanovIR
KardanovIR

Reputation: 492

The problem was in run command. You can't pass env variables after the container name. This command works:

docker run -e MYPREFIX_1=true -e MYPREFIX_DEMO=100 ... name 

Upvotes: 3

Related Questions