I am using a single Dockerfile to build images for different Ubuntu versions. Those images are then used in CI to build software targeting those different Ubuntu versions. Sometimes, there are of course some differences between Ubuntu versions, e.g. I'm installing different compilers. The code I use looks something like this:
FROM $baseimage AS base_image
ARG distro
ARG ${distro}=" "
...
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${focal:+10}${jammy:+14} 10
This used to work just fine but it doesn't seem to work anymore. -> BUG
Reproducing the Bug
Here's a minimal image to reproduce with full Dockerfile and build commands Dockerfile:
ARG baseimage
ARG distro
ARG ${distro}=" "
FROM $baseimage AS base_image
ARG distro
ARG ${distro}=" "
RUN echo "arg is ${distro}" > /test.log
RUN echo "distro is ${focal:+Focal}${jammy:+Jammy} ${focal:-not Focal}${jammy:-not Jammy}" >> /test.log
CMD sleep infinity
In this case, when using focal as test argument, I'd expect the log file contents to be:
arg is focal
distro is Focal not Jammy
However, instead it's:
arg is focal
distro is not Focalnot Jammy
I don't know what exactly changed to make it stop working, but I assume a recent docker upgrade (I'm on Ubuntu 22.04 here for building those images). But this used to work only a few months ago, and now it doesn't anymore.
With some help on StackOverflow I got it to work by setting DOCKER_BUILDKIT=0. So with this flag set, the above example Dockerfile and buildscripts behave correctly again.
Intro to the Bug
I am using a single Dockerfile to build images for different Ubuntu versions. Those images are then used in CI to build software targeting those different Ubuntu versions. Sometimes, there are of course some differences between Ubuntu versions, e.g. I'm installing different compilers. The code I use looks something like this:
This used to work just fine but it doesn't seem to work anymore. -> BUG
Reproducing the Bug
Here's a minimal image to reproduce with full Dockerfile and build commands Dockerfile:
build commands:
In this case, when using focal as test argument, I'd expect the log file contents to be:
However, instead it's:
I don't know what exactly changed to make it stop working, but I assume a recent docker upgrade (I'm on Ubuntu 22.04 here for building those images). But this used to work only a few months ago, and now it doesn't anymore.
With some help on StackOverflow I got it to work by setting
DOCKER_BUILDKIT=0
. So with this flag set, the above example Dockerfile and buildscripts behave correctly again.