Docker Community Forums

Share and learn in the Docker community.

Build from specific tag without changing Dockerfile?


(Ceharris414) #1

In a largish application, our CI builds a base image that is then used as the parent image for the image containing the application itself. The base image can change in a particular feature branch, so it’s important that the base image for that branch is used to build the application image for that branch. Because there can be multiple concurrent builds on different branches underway, using latest isn’t really what we want.

We’ve been addressing this use case by passing the Dockerfile through sed to add a tag that identifies the feature branch to the FROM directive. So when building the application image, we replace FROM namespace/base with FROM namespace/base:branchTag.

This works, but it seems like something that would be a common enough need that there should be a way to do this without modifying the Dockerfile; i.e. it seems like I ought to be able to specify a tag for the FROM image on the docker build command line. Am I missing something here?