Skip to content
Go back

Pick the Right Distroless Base Image For Your Application

Updated:
Edit page

docker challenge https://labs.iximiuz.com/challenges/pick-the-right-distroless-base-image

image

root@docker-01:~# file server
server: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=016df6500c2c3df1dd3ce82d9e9a5bd547584c97, for GNU/Linux 3.2.0, with debug_info, not stripped
root@docker-01:~# ldd server
        linux-vdso.so.1 (0x00007ffde5df1000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbc097e4000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fbc0a379000)

[!NOTE]

linux-vdso.so.11 没有实体文件,文件 GNU/LINUX 编译,那么需要 libc,动态连接 /lib64/ld-linux-x86-64.so.2

FROM scratch

COPY ./server /server
COPY ./libc.so.6 /lib/x86_64-linux-gnu/libc.so.6
COPY ./ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2

CMD ["/server"]
FROM golang:alpine as builder
RUN apk update && apk upgrade && apk add --no-cache ca-certificates
RUN update-ca-certificates

FROM scratch

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY ./server /server
COPY ./libc.so.6 /lib/x86_64-linux-gnu/libc.so.6
COPY ./ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2

CMD ["/server"]

Footnotes

  1. https://stackoverflow.com/questions/58657036/where-is-linux-vdso-so-1-present-on-the-file-system

  2. https://serverfault.com/questions/1092830/docker-copy-fails-with-no-such-file-or-directory-but-i-am-root-and-can-access-t

  3. https://gist.github.com/michaelboke/564bf96f7331f35f1716b59984befc50


Edit page
Share this post on:

Previous Post
如何使用 git 拉取部分文件
Next Post
CF 的优化导致 Astro build static file 的 script 失效