When using that ARG
option in your Dockerfile, you can specify the --build-args
option to define the value for the key that you specify in your Dockerfile to use for a environment variable as an example.
Today we will use the arg
and env
to set environment variables at build time.
The Dockerfile:
Our Dockerfile
1 2 3 4 |
|
Building our Image, we will pass the value to our NAME argument:
1
|
|
Now when we run our container, we will notice that the build time argument has passed through to our environment variable from the running container:
1 2 |
|
When we build the image without specifying build arguments, and running the container:
1 2 3 |
|
Thank You
Please feel free to show support by, sharing this post, making a donation, subscribing or reach out to me if you want me to demo and write up on any specific tech topic.
Ad space:
Thanks for reading!