You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
When using a variable in a heredoc, buildkit and buildah have different behaviour:
buildkit will retain the variable, buildah will not.
Steps to reproduce the issue:
Use the following Containerfile
FROM bash
ARG MY_ARG=wombat
RUN <<EOF
set -euo pipefail
tempvar=$MY_ARG
if [ $tempvar == "wombat" ]; then
exit 0
else
exit 99
fi
EOF
and observe the following results:
docker build . -f Containerfile -> build succeeds
buildah build . -> build fails with error
sh: wombat: unknown operand
Error: building at STEP "RUN <<EOF": while running runtime: exit status 99
Describe the results you expected:
Matching behaviour across docker build and buildah build
In particular for a heredoc, the ability to compute a temporary result once and then reuse it later is very useful - for instance downloading a specific file, then validating the signature and/or the checksum. docker build allows that.
Docker version in use:
❯ docker --version
Docker version 25.0.4, build 1a576c50a9
(which is larger than 23.0, i.e. buildx / buildkit is in use)
Output of rpm -q buildah or apt list buildah:
❯ pacman -Ss buildah
extra/buildah 1.35.0-1 [installed]
A tool which facilitates building OCI images
For reference I have pasted a more useful heredoc below. This hopefully makes the point that temporary variables - as supported by buildx / buildkit - are quite a useful thing to have.
Note that this example abuses an ARG to create a temporary variable, and to work around the problem described above. I'd love to simply compute this inside the heredoc.
ARG __ORIGINAL_DOWNLOAD_FILENAME=kafka_$SCALA_VERSION-$KAFKA_VERSION.tgz
RUN <<EOF
set -euo pipefail
mkdir -p /opt
curl -fL https://downloads.apache.org/kafka/$KAFKA_VERSION/$__ORIGINAL_DOWNLOAD_FILENAME \
-o $__ORIGINAL_DOWNLOAD_FILENAME
#
# NOTE:
# Deliberately breaking in case we switch to a different version of Kafka
#
cat > $__ORIGINAL_DOWNLOAD_FILENAME.sha512 <<SHA512
kafka_2.13-3.7.0.tgz: B8679283 A2D8DAB8 6E7C636B 2C688FE9 D9E64AC4 37241F65
EF7A1733 F4D26A2B D415EEFA 04F09F19 11373BCD 2A5DBC38
38C76347 F6865642 5C09202C D290CE91
SHA512
GNUPGHOME=$(mktemp -d) gpg --print-md SHA512 $__ORIGINAL_DOWNLOAD_FILENAME \
| diff - $__ORIGINAL_DOWNLOAD_FILENAME.sha512
tar --directory /opt --extract --gzip --file $__ORIGINAL_DOWNLOAD_FILENAME
EOF
Description
When using a variable in a heredoc, buildkit and buildah have different behaviour:
buildkit will retain the variable, buildah will not.
Steps to reproduce the issue:
Use the following
Containerfile
and observe the following results:
docker build . -f Containerfile
-> build succeedsbuildah build .
-> build fails with errorDescribe the results you expected:
Matching behaviour across
docker build
andbuildah build
In particular for a heredoc, the ability to compute a temporary result once and then reuse it later is very useful - for instance downloading a specific file, then validating the signature and/or the checksum.
docker build
allows that.Docker version in use:
(which is larger than 23.0, i.e. buildx / buildkit is in use)
Output of
rpm -q buildah
orapt list buildah
:Output of
buildah version
:Output of
cat /etc/*release
:Output of
uname -a
:Output of
cat /etc/containers/storage.conf
:n/a
The text was updated successfully, but these errors were encountered: