New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal - Build multiple images from a single repository #9198
Comments
Arnaud, check out my comment here: #7284 (comment) #7284 (comment) This itemizes a lot of things I’d like to see in this feature, specifically, the notion of a
|
Thanks for collecting these in a single proposal. I largely can find myself in this (taking into account Eriks comment) I do think, however, that having multiple Dockerfiles for the same context is a common use case. Because of this, consider including |
A Dockerfile currently can't directly control how an image is named (only Also did you consider making the context the same for the 3 builds so that SubDirectoryA and SubdirectorB can share files to I'd also like to highlight @drewcrawford comments on #2112 (comment) about proper support for build targets. I wonder if we could (or should?) take this proposal further into a proper It could uses another file like your proposal, but instead of inferring the name from the directory (or the file suffix), it would explicit require you to specify a set of
|
@erikh The reason I favor "scattered" Dockerfiles instead of a specific directory holding them all is that I believe it makes assumptions on the context clearer. Here the build context is always scoped to the Dockerfile location, as expected today, and I'm for keeping this behavior. @thaJeztah Noted, will update. @proppy Only the Dockerfile relative location is part of the resulting image names (by being concatenated to the I'm updating the proposal, thank you all for your comments. |
true, and it would also create confusion w/ different contexts depending of you build a sub image from its own root, or from the parent. But still I think that @jpetazzo has a point, often you want to share a piece of code from the same source directory between multiple images. And there is no easy way to do that today, even with separate
I think it would be useful to give the user more control on the name, too. @icecrime, maybe something like this would work, context is still the
|
Just stumbled across this proposal, and it seems like there's a lot of overlap with #7115
I personally find #7115 more powerful, as it allows the builds to interact with each other (pass data), which opens up a lot of options. If it can be tweaked to support all the objectives of this proposal (and it sounds like it easily can), I would favor it. |
Any news here? |
Yes, this was implemented in #9707, which is in Docker 1.5 and up, so this can be closed |
Sorry for this not being a doc first proposal: I’d like to go through the design before proceeding with the documentation itself (it introduces a new magic file, hence probably a whole new documentation page).
Issue statement
Docker needs to provide a repeatable and well defined mechanism for repositories which builds into multiple image. Existing proposals:
These have been opened for some time, and have reached the point where tempers flaring and amount of noise overwhelms the signal. The thinking behind this new proposal was driven by the following remarks collected from previous debates:
docker build
to behave consistently, without repository-specific knowledgeDockerfile
s at its rootDockerfile
verbs are more difficult to introduceProposal
We introduce a new magic file at the root of the repository to act as the
Dockerfile
of allDockerfile
s:DockerfileIndex
(as I believeDockerfiles
is too error prone and confusing)Dockerfile
, meaning that adocker build
invoked in a directory containing both aDockerfile
and aDockerfileIndex
interprets theDockerfileIndex
onlyDockerfile
s' relative pathsWith the above
DockerfileIndex
, the invocation ofdocker build -t basename:tag .
at the root of the repository is equivalent to the following sequence of commands:Notes:
Dockerfile
is itself listed on the first line of theDockerfileIndex
(there is nothing specific to thisDockerfile
nor to the root)DockerfileIndex
interpretation would occur on the client side with multiplebuild
API callsDockerfile
: this is Docker current behavior, and I also strongly believe it is the least astonishing one.Different builds with a single context
To allow for multiple builds using a same context, we require multiple
Dockerfile
in a single directory: these differentDockerfile
would be disambiguated using suffixes, such asDockerfile.A
andDockerfile.B
. GivenDockerfileIndex
:Invocation of
docker build -t basename:tag .
would result in imagesbasename/A:tag
andbasename/B:tag
to be created. Image name is scoped byDockerfile
location first and filename suffix second, which means thatSubDirectoryA/Dockerfile.Type1
build would produce imagebasename/SubDirectoryA/Type1
.Possible extensions
These probably doesn’t have to come in a first version:
DockerfileIndex
location through the use of an additionaldocker build
flag (--only
was suggested).History
The text was updated successfully, but these errors were encountered: