According to the documentation, it's possible to define multiple args for the flag --build-arg
, but I can't find out how. I tried the following:
docker build -t essearch/ess-elasticsearch:1.7.6 --build-arg number_of_shards=5 number_of_replicas=2 --no-cache .
=> This returns an error.
I also tried:
docker build -t essearch/ess-elasticsearch:1.7.6 --build-arg number_of_shards=5,number_of_replicas=2 --no-cache .
=> This sets one variable, number_of_shards
, to the value "5,number_of_replicas=2"
Any idea how I can define multiple arguments?
If you want to use environment variable during build. Lets say setting username and password.
Dockerfile
Terminal Command
docker build --build-arg SMB_PASS=swed24sw --build-arg SMB_USER=Ubuntu . -t IMAGE_TAG
Use
--build-arg
with each argument.If you are passing two argument then add
--build-arg
with each argument like:The above answer by pl_rock is correct, the only thing I would add is to expect the ARG inside the Dockerfile if not you won't have access to it. So if you are doing
Then inside the Dockerfile you should add
I was running into this problem, so I hope I help someone (myself) in the future.
It's a shame that we need multiple ARG too, it results in multiple layers and slows down the build because of that, and for anyone also wondering that, currently there is no way to set multiple ARGs.