You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Aleksey Zubakov
ad77de3670
|
2 years ago | |
---|---|---|
.. | ||
Dockerfile | 2 years ago | |
README.md | 2 years ago | |
demo.sh | 2 years ago | |
file.env | 2 years ago |
README.md
Lesson 6: Environment variables and configuration
-
Change directory into
lesson06
. -
A popular way to provide configuration information to a docker container is via environment variables.
-
Let's try it:
$ docker build . -t demo $ docker run -it --rm --name fuzzle demo
-
Does the output make sense?
-
Let's pass in a value for the environment variable
HELLO_WORLD
:$ docker run -it --rm --name fuzzle -e HELLO_WORLD='Hello, world.' demo
-
You can also pass in environment variables via a file:
$ cat file.env # We define two environment variables (you CAN comment!) HELLO_WORLD="Hello, world." ENV_VAR2="another environment variable" $ docker run -it --rm --name fuzzle --env-file=file.env demo
-
If your Docker application does not have many configuration options configuring via environment variables is a good method. However, if the application has complicated or extnesive configuration this may not be feasible.
-
Don't forget to clean up:
$ docker rmi demo:latest (removes the image demo:latest)