canonical / chisel

GNU Affero General Public License v3.0
270 stars 42 forks source link

chisel does not generate correct image for Ubuntu 24.04? #140

Closed flashdma closed 3 months ago

flashdma commented 3 months ago

Hello!

I'm using the below Dockerfile:

ARG UBUNTU_RELEASE=24.04

# Stage 1
FROM golang as chisel

RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates git \
    && apt-get clean -y \
    && rm -rf /var/lib/apt/lists/*

RUN go install github.com/canonical/chisel/cmd/chisel@latest

# Stage 2
FROM ubuntu:${UBUNTU_RELEASE} AS installer
COPY --from=chisel /go/bin/chisel /bin/

RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates git \
    && apt-get clean -y \
    && rm -rf /var/lib/apt/lists/*

ARG UBUNTU_RELEASE

WORKDIR /rootfs

RUN chisel cut --release ubuntu-${UBUNTU_RELEASE} --root /rootfs coreutils_bins
RUN find /rootfs/

# Stage 3
FROM scratch
COPY --from=installer [ "/rootfs/", "/" ]
WORKDIR /usr/bin
CMD [ "ls" ]

If I build it and run, then I get the below error:

exec /usr/bin/ls: no such file or directory

If I change UBUNTU_RELEASE parameter to 22.04 in the Dockerfile, then everything works as expected. Am I doing something incorrectly or there is a problem with Ubuntu 24.04 support?

rebornplusplus commented 3 months ago

Hiya!

So, to run these binaries, the glibc libraries are needed. While you are actually installing them, docker can't find it in 24.04 because there are no /lib/ or /lib64/ paths in the rootfs. In 22.04, those paths are created while installing the libc6 and other library slices. But in 24.04, the libraries are installed in /usr/lib/ and base-files is the package which symlinks /lib/ to /usr/lib/.

Install the base-files_base slice too and things should work. You can get away with only installing the library paths from base-files_lib slice if you do not want all the paths from the base slice.

Let me know if it works. Cheers!

flashdma commented 3 months ago

Thank you very much! I added base-files_lib slice and it works now!