I'm trying to build a Docker container whose source tag I want to pass as a parameter.
Build script:
docker build \
--pull=true \
...
--build-arg version=${version}
The Dockerfile:
ARG version
FROM registry/repo:${version}
Running this gives me the error Please provide a source image with
fromprior to commit
.
Is there any way I can pass the version to pull as a build argument and use it? I'm on docker version 1.12
According to the docs, the first instruction needs to be FROM
(or technically a parser directive, but not relevant here) so this approach likely isn't going to work. Probably some shell wrapper around docker build...
with some sed
command or something to insert the correct version, or a template of some kind.
Gareth Rushgrove had a nice talk at DockerCon16 on image build tooling that might be interesting.
Update (7/2/17): This is now possible to achieve since v17.06.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With