Thursday, June 14, 2018

Docker ENV vs ARG

There are two types of variables in a Dockerfile, ENVs and ARGs. YOu define them in the Dockerfile like this:

ARG some_argument

This requires that you run:

$docker build --build-arg some_argument=something

Then there's ones with a default value.

ARG some_argument="default value"

You don't have to specify it during the docker build, but you can if you want.

ENV some_value=something
ENV some_other_value=${some_argument}

You can override these when you do docker run:

$docker run -e "some_value=others_stuff" ...

No comments:

Post a Comment