How to squash Dockerfiles?

Assume I have a hierarchy of images, one inheriting from the other with FROM:

  • B: FROM A
  • C: FROM B
  • D: FROM C

A is a standard base image, and B,C,D are my own images.

  • Artifactory pro server behind an nginx frontend
  • Creating a network on docker swarm between docker-compose applications and other containers
  • Concourse add file to docker image just once
  • SSH from Docker image using Drone
  • Simple example of Vagrantfile / Dockerfile to run node app
  • Defining services in kubelet manifest
  • Now I need to create a Dockerfile for D’, with same additions coming from Dockerfiles of B, C and D, but based on a different base image – A’.

    I can think of a couple of ways to achieve this:

    1. Create dockerfile for B’, identical to B but inheriting from A’. Same for C’ and D’.
    2. Create a completely new Dockerfile for D’, with base image A’ and copy-pasting all the commands from dockerfiles of B, C and D.

    Is there a better way to achieve this? I guess a tool/scrtipt that would do #2 might be enough.

  • Run project dependencies commands from dockerfile
  • docker alpine postgres in compose not executing docker-entrypoint-initdb.d scripts
  • How to fix insecure-registry error on clients by updating the docker registry server
  • Adding a directory from the host filesystem to the docker filesystem (not in a dockerfile)
  • Stop Minecraft server in Docker when container stops
  • docker swarm - etcd cluster is unavailable or misconfigured
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.