Docker - Build Arg in source file

I am trying to create a Docker container whose source tag I want to pass as a parameter.

Build script:

docker build \ --pull=true \ ... --build-arg version=${version} 

Docker File:

 ARG version FROM registry/repo:${version} 

Doing this gives me an error. Please provide a source image with from prior to commit .

Is there a way to pass the version in order to pull it out as a build argument and use it? I'm on docker version 1.12

+9
source share
1 answer

According to the docs , the first instruction should be FROM (or technically a parser directive, but not relevant here), so this approach is unlikely to work. Probably the shell shell around docker build... with some sed command or something to insert the correct version or some kind of template.

Gareth Rushgrove had a good chat with DockerCon16 in the field of image creation, which can be interesting.

Update (7/2/17): now can be achieved with v17.06 .

+13
source

Source: https://habr.com/ru/post/1011736/


All Articles