Docker Community Forums

Share and learn in the Docker community.

Dockerfile ONBUILD FROM Support


#1

Why did Docker remove support for the “ONBUILD FROM” syntax?

We have many services whose Dockerfiles all start the same way. We’d like to create a base image that the services could share, so that we don’t have to copy the same set of instructions to the top of every Dockerfile. As an example, our base image would look like this:

ONBUILD FROM ubuntu:16.04
ONBUILD RUN <install some utilities we always need>
ONBUILD RUN <install some files we always want>

And then the Dockerfiles for our services could just contain:

FROM base
RUN <install service-specific files>

When we build our service, we would automatically execute all of the shared commands in the base image above, and our service Dockerfile would only have to include service-specific commands.

A way around this would be to set up the base image in the following manner:

FROM ubuntu:16.04
ONBUILD RUN <install some utilities we always need>
ONBUILD RUN <install some files we always want>

However, then we would always have to rebuild our base image whenever an update to Ubuntu has been published.

This seems like a really useful feature for maintaining a large number of services that have similar configuration. Anyone know why Docker doesn’t allow it anymore?