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
I've been using buildah's multi-container feature to create slim runtime images for a while now (something inspired by https://projectatomic.io/blog/2017/08/buildah-getting-fit/) - a technique to have a separate container or host with package manager and have a target runtime container where packages are installed. (OpenSUSE project even provides images for such purpose - they contain RPM database, but no rpm).
However this process requires a bit of scripting to start containers and juggle with mounts and is not that expressive.
Recently I discovered that Dockerfile syntax now allows to add a different set of mounts to RUN instruction, so I tried to check if it's possible to achieve same effect with just Containerfiles:
FROM registry.opensuse.org/opensuse/bci/bci-micro:latest AS base
RUN echo "Building..."# ^^^^^^^^ This commits container to an image. The image will be (re)used in the final stageFROM registry.opensuse.org/opensuse/tumbleweed AS zypp
RUN zypper modifyrepo --keep-packages --all
RUN \
--mount=type=cache,destination=/var/cache/zypp \
--mount=type=bind,from=base,destination=/target,rw \
zypper --non-interactive --gpg-auto-import-keys --installroot=/target install ripgrep
# ^^^ This modifies running container, but not the image. Image is committed after finishing "base" stageFROM base
RUN --mount=type=bind,from=zypp,destination=/root echo "Done building"# ^^^^ This is just to add dependency on zypp stage, otherwise it is ignored.
Unfortunately it doesn't work, because while RUN instructions take stage as a container, FROM instructions take stage as an image. The difference is that container is committed to image right before switching to the next stage (FROM tumbleweed AS zypp) and therefore any changes done to base container are not propagated (just discarded).
So that's my question - is there any way to create Containerfile which allows such use-case?
P.S. thanks for a great tool!
The text was updated successfully, but these errors were encountered:
Hi!
I've been using buildah's multi-container feature to create slim runtime images for a while now (something inspired by https://projectatomic.io/blog/2017/08/buildah-getting-fit/) - a technique to have a separate container or host with package manager and have a target runtime container where packages are installed. (OpenSUSE project even provides images for such purpose - they contain RPM database, but no rpm).
However this process requires a bit of scripting to start containers and juggle with mounts and is not that expressive.
Recently I discovered that Dockerfile syntax now allows to add a different set of mounts to
RUN
instruction, so I tried to check if it's possible to achieve same effect with just Containerfiles:Unfortunately it doesn't work, because while
RUN
instructions take stage as a container,FROM
instructions take stage as an image. The difference is that container is committed to image right before switching to the next stage (FROM tumbleweed AS zypp
) and therefore any changes done to base container are not propagated (just discarded).So that's my question - is there any way to create Containerfile which allows such use-case?
P.S. thanks for a great tool!
The text was updated successfully, but these errors were encountered: