Closed seantrons closed 9 months ago
Simpler reproducer:
$ cat /tmp/Dockerfile
FROM alpine:3.17
ENV PATH_FOO=/foo
WORKDIR ${PATH_FOO}/bar
RUN pwd
$ ch-image build --rebuild /tmp
inferred image name: tmp
1* FROM alpine:3.17
2. ENV PATH_FOO='/foo'
updating existing image ...
3. WORKDIR /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin_FOO}/bar
4. RUN.S pwd
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin_FOO}/bar
--force=seccomp: modified 0 RUN instructions
grown in 4 instructions: tmp
pwd(1)
should print /foo/bar
. It looks like it’s expanding $PATH
instead of $PATH_FOO
.
Version Info:
While working on a minimal project I'm using to debug some MPI-in-container issues, I noticed some oddities in Charliecloud's behavior which occur during the build process when expanding variables in a Dockerfile.
Located at the bottom of this issue is a Dockerfile definition representing a minimal build for debugging components in a containerized MPI installation. Inside, a number of environment variables are first defined and later referenced in the build steps. Note that some like
ENV PATH="<path-to-something>:$PATH"
are defined merely to simplify the use of binaries and libraries later on within the container.Attached are two different build logs. The first is from building the container locally with Docker (version 24.0.5 on Darwin/MacOS Big sur) and the second results from taking the same action with Charliecloud in a HPC cluster environment.
In the Charliecloud build, the variables either do not expand or in some cases the expansion is performed prematurely, causing the substitution of incorrect values. For an example, in this Dockerfile when Charliecloud attempts to expand
${PATH_INSTALL_BASE}
, it instead expands$PATH
and appends_INSTALL_BASE}
to the end of the expansion.In addition to the early expansion, I noticed that all of environment variables defined in the build file were not present in the resulting environment built with Charliecloud (for a full Charliecloud build, remove all references to the variables in commands below their definitions and replace with the appropriate static string content).
Dockerfile DEF:
build.log.docker.md build.log.charliecloud.md