Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Proposal: INCLUDE syntax for specifying multiple images per context #7277
Multiple use cases call for an ability to build several Docker images from a single context. An example would be a set of microservices that reside in a shared repository, because they also share common libraries. The common folder layout looks like this:
An ideal solution would:
This proposal is to introduce a new verb in the Dockerfile that would look like this:
The INCLUDE verb can be used multiple times. If there is an INCLUDE in a Dockerfile, it must come before the FROM verb in that file and FROM verb becomes optional.
If such line is included in the root Dockerfile and a user runs
In addition it should be possible for a user to run
Tag ":included" should be considered to be equivalent to ":latest" (possibly with a warning) if there is no build with such name in the current build set.
CONTEXT verb shifts the context for a Docker build relative to the Dockerfile. This can be used to only have a subfolder of the original context be uploaded to the daemon. It can also be used to shift the context folder up, but only if the Dockerfile is included in another Dockerfile higher in the path and only up to the folder of the top level Dockerfile.
referenced this issue
Jul 28, 2014
Why wouldn't you just make a shell script to run the different builds? This seems to be a very specific use-case (and is filled with strange functionality, because the context of each
Using shared libraries is a bit of a pain, and the builder-runner pattern can help with this (you have a build of the builders of the shared libraries, then a build of the builders each app and then a build of the runners for each app).
Also, the whole recipe thing can be done with a
referenced this issue
Jul 29, 2014
I agree that there is a context confusion when looking at individual Dockerfiles. To alleviate that I propose adding another command - CONTEXT:
Updated the proposal.
Also as a comment - builder/runner pattern is very painful to use. And it also breaks the pattern of "docker build ." doing the right thing. This #7115 has a quite heavy syntax in the file. I would prefer the combination of this with #6906 (comment) this to solve such issues.
It does miss a few nice things from #7115 , namely the ability to build in one environment (such as full Debian) and then run in something completely different (like busybox) or to combine multiple outputs, but the syntax is much simpler. And it could actually be merged with #7115 in a way to allow the use of separate images and separate Dockerfiles to define the sub-images.
So the example from #7115 could be reformulated as: