Answer the question
In order to leave comments, you need to log in
How to set an environment variable in Docker?
Good day!
In the secret.py file , a certain sequence of characters is generated and displayed on the screen
def gen_secret():
return "some secret"
print(gen_secret())
#!/bin/sh
export SECRET=$(python util/secret.py)
echo $SECRET
Answer the question
In order to leave comments, you need to log in
Option 1:
docker-compose.yml:
...
env_file: .env
...
environment:
- SECRET=value
docker run --env-file .env ...
1) You can add environment:
SECRET : VALUE
to your container directly in the docker-compose.yml file
2) Or write your bash script in the dockerfile.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question