In the past I’ve ended up installing a bunch of development tools and dependencies on my workstation OS. Then these have updates and the whole system has updates and I do `dnf update` and suddenly who knows what is broken. Meanwhile I want to tweak this, use a development version of that, etc. Before I know it my system is a giant ball of mud.

Well, I just got a new laptop and This Time It Will Be Different. This is a problem that containers were meant to solve. I will have only the necessary GUI packages installed on the host, and everything else will go into containers with a few tools for invoking them with all the necessary options (directories mounted in, user set, etc.) and updating them as needed. Wish me luck.

This basically means setting up each development environment from scratch in a container instead of on the host… teasing out which things from my old configurations were relevant to each thing. This will definitely create new management headaches… well, it will be a learning experience.

imagebuilder. It’s a bare-bones “docker build” client with some defaults more geared toward automated builds. There’s no caching of layers and no squashing of layers at the end. It can do multi-stage builds.

There’s a -from option for overriding FROM. What happens with that in a multi-stage build? Let’s find out.

First I ran into a problem. After I ran imagebuilder, the image wouldn’t run:

$ docker run -it 6eccbc13a8bb /bin/bash
/usr/bin/docker-current: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: not a directory"

Quick internet search gave no clues. Trying a more minimal build, I still was seeing weird stuff: exec: “sleep 86400”: executable file not found in $PATH · Issue #68 · openshift/imagebuilder · GitHub

That seemed related but I’m trying to get at the inability to even run bash explicitly. Ah, finally figured it out:

COPY --from=0 foo /usr/bin

Without a trailing / this turns /usr/bin into a file. OK, my stupid mistake. At least I figured that out.

To answer the original question: if you specify –from on a multistage build, it overrides only the first FROM in the Dockerfile.