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
FROM alpine AS get-chisel
ARG CHISEL_VERSION=1.1.0
ARG TARGETARCH
ARG CHISEL_RELEASE="https://github.com/canonical/chisel/releases/download/v${CHISEL_VERSION}/chisel_v${CHISEL_VERSION}_linux_${TARGETARCH}.tar.gz"# NOTE: `--no-same-owner` used as `chisel` release has ownership of `1001:128`RUN wget -qO - "${CHISEL_RELEASE}" | tar -xz --no-same-owner -C /usr/local/bin chisel
FROM scratch AS chisel
# Copy over chisel binary and it's external dependency to `ca-certificates.crt`:COPY --link --from=get-chisel /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --link --from=get-chisel /usr/local/bin/chisel /usr/local/bin/chisel
# Provision bash and make it the default shell for `RUN`:RUN [ "/usr/local/bin/chisel", "cut", "--release", "ubuntu-24.04", "--root", "/", "base-files_base", "bash_bins" ]
SHELL [ "/bin/bash", "-c" ]
# This fails:RUN chisel cut --release ubuntu-24.04 --root / base-passwd_data
If the last line is replaced with the following, it would work:
WORKDIR /root-fs
RUN chisel cut --release ubuntu-24.04 --root /root-fs base-passwd_data
I'm not sure if other slices would be similarly affected by this failure for --root /, it is unclear why the slice only fails with --root /? It doesn't seem to be about any conflict with existing directories AFAIK, I have run chisel from a different path than /usr/local/bin/chisel (such as /chisel instead) but it still fails with this error.
NOTE: This same error for the affected slice was reported in June 2022 but was related to a relative --root (using --root ./ or --root . for relative path does not help however).
Thanks for reporting this. It is an issue of how we handle the root being only a single slash (/) in the code. The fix is very simple, getting the testing to be comprehensive is going to be a bit more difficult but we are going to look into it.
I tried to reproduce a scenario I encountered at some point after reporting this issue, but was unsuccessful.
I recall doing something where chisel populated /etc/passwd and /etc/group with FIXME instead of actual user/groups. I suppose a slice added the files with that content, but didn't mutate it. I think that was only the case with --root /, while --root /root-fs was fine.
Using a separate stage to add and modify users/groups, then COPY to chisel stage
FROM alpine AS base
# Minimal version of these two files,# Users: `root` + `nobody` + `nonroot`, and extra `tty` + `staff` (base-files).COPY --link --from=gcr.io/distroless/static-debian12 /etc/passwd /etc/passwd
COPY --link --from=gcr.io/distroless/static-debian12 /etc/group /etc/group
RUN apk add shadow \
&& useradd --system --uid 500 --user-group --create-home --home /var/lib/clamav --shell /usr/sbin/nologin clamav
# Use `chisel` here:FROM scratch
COPY --link --from=base /etc/group /etc/group
COPY --link --from=base /etc/passwd /etc/passwd
That was based on my findings here when looking into how to best add new users.
Embedding the files directly with custom user
# NOTE: You can use build args within the file content if you need extra flexibility:ARG NEW_USER=clamav
COPY <<HEREDOC /etc/passwd
root:x:0:0:root:/root:/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/sbin/nologin
${NEW_USER}:x:500:500:ClamAV:/var/lib/${NEW_USER}:/sbin/nologin
HEREDOC
COPY <<HEREDOC /etc/group
root:x:0:
nobody:x:65534:
tty:x:5:
${NEW_USER}:x:500:
HEREDOC
# Optionally create home dir:RUN --mount=type=bind,from=busybox:latest,source=/bin,target=/bin \
install --directory --mode 2775 --owner clamav --group clamav /var/lib/clamav
I suppose another approach (beyond external files with ADD/COPY) is a custom slice, but presently that's a bit more to support due to how --release works with custom slices requiring a full clone to overlay onto a release channel 😅
Activity
letFunny commentedon May 2, 2025
Thanks for reporting this. It is an issue of how we handle the root being only a single slash (
/) in the code. The fix is very simple, getting the testing to be comprehensive is going to be a bit more difficult but we are going to look into it.polarathene commentedon May 2, 2025
I tried to reproduce a scenario I encountered at some point after reporting this issue, but was unsuccessful.
I recall doing something where chisel populated
/etc/passwdand/etc/groupwithFIXMEinstead of actual user/groups. I suppose a slice added the files with that content, but didn't mutate it. I think that was only the case with--root /, while--root /root-fswas fine.I wanted to add a new user without the extra weight of
passwd_bins(or futureadduser_binsslice).Using a separate stage to add and modify users/groups, then COPY to chisel stage
That was based on my findings here when looking into how to best add new users.
Embedding the files directly with custom user
Append to files directly via shell commands
I suppose another approach (beyond external files with
ADD/COPY) is a custom slice, but presently that's a bit more to support due to how--releaseworks with custom slices requiring a full clone to overlay onto a release channel 😅upils commentedon Mar 2, 2026
Closing as solved by #224