-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Closed
Labels
area/builderBuildBuildkind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shinyFunctionality or other elements that the project doesn't currently have. Features are new and shiny
Milestone
Description
I propose that docker build accept -f - to indicate that the Dockerfile to be used is read from the STDIN of the docker client process.
Use cases
- Shared engine CI systems can now stack anonymous image builds easily without requiring intermediate directories or tar archives
- Dockerfiles in local directories, tar archives, and git repos can now be overridden
docker buildis now a versatile shell scripting command as Dockerfiles can participate in shell pipelines decoupled from file system contexts
New capabilities
- Uncooperative remote tar archives and git repos can now have out-of-band Dockerfiles applied to them
- Local directory builds can now have Dockerfiles imported for just the build via I/O redirection
Design considerations
- A
-stdin reader interface already exists in the context path argument so any-f -implementation will have to accommodate that - Accepting
-in place of file paths is a common UNIX idiom to indicate that what would have been read from the path specified should instead be read from stdin; this makes havingdockerparticipate in UNIX pipelines much easier - This feature could be abused to avoid Best Practice so all advice regarding application/system design should be maintained and users should be encouraged to place Dockerfiles in repositories and tarballs so builds are straightforward and unambiguous when possible
Cases
builder.GetContextFromReader(builder/context.go) is used to read a context (or Dockerfile only) from stdin: nothing will change, a file called-will still be sourced from the stdin tarball (or still ignored in the case ofDockerfileonly on stdin)builder.GetContextFromGitURL(builder/context.go) is used to read a context from a git URL and the resultant context will have itsDockerfilerewritten and used for the buildbuilder.GetContextFromURL(builder/context.go) is used to read a context from a remote URL and the resultant context will have itsDockerfilerewritten and used for the build (or ignored in the case of aDockerfileonly context)builder.GetContextFromLocalDir(builder/context.go) is used to read a context from a local directory and the resultant context will have itsDockerfilerewritten and used for the build
Implementation
I've prototyped this functionality by rewriting the tar stream of the context before the trusted pull rewriting. If there is interest in this functionality, I will clean up my prototype and submit a PR. I welcome your ideas regarding this or similar features. Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/builderBuildBuildkind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shinyFunctionality or other elements that the project doesn't currently have. Features are new and shiny