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
env to set environment variables at build time.
1 2 3 4
Building our Image, we will pass the value to our NAME argument:
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:
When we build the image without specifying build arguments, and running the container:
1 2 3
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.
Thanks for reading!