Reputation: 3
With the support of the multi-stage builds, it has become convenient to maintain repos up to a point. But how can you extend these repos?
Up to now, you can build an image of a specific tag using the --target
in the docker build
command.
From docker-compose, you can use the target
entry in the context
entry to specify it.
In my case, I want to use an image from docker hub and extend a specific target. Right now, I am using a Dockerfile (which I call from docker-compose but that shouldn't matter) which has the
FROM repo/sample-name
DO my stuff
That repo has 3 targets in their Dockerfile named sample-name
, sample-name-full
which extends sample-name
and sample-name-dev
which extends sample-name-full
. The dashes in these names are just like the repo named their targets.
What seems to be happening is that I am getting the first target as the build target (or I think I do) which is named after the repo itself. How can I, let's say, extend the intermediate target?
I tried stuff like
FROM repo/sample-name:latest-sample-name-dev
etc but I could not make it work.
Upvotes: 0
Views: 604
Reputation: 12129
This is not possible by design. One advantage of the multi-stage build is to hide intermediate stage, an example could be to download something with hard coded credentials in the first stage and then in the second stage copy the result from it. The final image, as is available on the dockerhub, is ostensibly single-stage built. Most the time you won't worry about this as the final stage has acquired all useful things from previous ones.
Upvotes: 1