Skip to content

Commit 81436d3

Browse files
committed
Dockerfile: add systemd units from the upstream + fix stargz
Signed-off-by: Akihiro Suda <[email protected]>
1 parent f1e3bdd commit 81436d3

File tree

5 files changed

+26
-89
lines changed

5 files changed

+26
-89
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ build
77

88
# vagrant
99
/.vagrant
10+
11+
# dockerfile itself
12+
Dockerfile

Dockerfile

+16-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ ARG TARGETARCH
3636
ARG CONTAINERD_VERSION
3737
RUN curl -L https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERSION}/containerd-${CONTAINERD_VERSION}-linux-${TARGETARCH:-amd64}.tar.gz | tar xzvC /out && \
3838
rm -f /out/bin/containerd-shim /out/bin/containerd-shim-runc-v1 && \
39+
mkdir -p /out/lib/systemd/system && \
40+
curl -L -o /out/lib/systemd/system/containerd.service https://raw.githubusercontent.com/containerd/containerd/v${CONTAINERD_VERSION}/containerd.service && \
3941
echo "- containerd: v${CONTAINERD_VERSION}" >> /out/share/doc/nerdctl-full/README.md
4042
ARG RUNC_VERSION
4143
RUN curl -L -o /out/bin/runc https://github.com/opencontainers/runc/releases/download/v${RUNC_VERSION}/runc.${TARGETARCH:-amd64} && \
@@ -52,8 +54,15 @@ ARG BUILDKIT_VERSION
5254
RUN curl -L https://github.com/moby/buildkit/releases/download/v${BUILDKIT_VERSION}/buildkit-v${BUILDKIT_VERSION}.linux-${TARGETARCH:-amd64}.tar.gz | tar xzvC /out && \
5355
rm -f /out/bin/buildkit-qemu-* /out/bin/buildkit-runc && \
5456
echo "- BuildKit: v${BUILDKIT_VERSION}" >> /out/share/doc/nerdctl-full/README.md
57+
# NOTE: github.com/moby/buildkit/examples/systemd is not included in BuildKit v0.8.x, will be included in v0.9.x
58+
RUN cd /out/lib/systemd/system && \
59+
sedcomm='s@bin/containerd@bin/buildkitd@g; s@(Description|Documentation)=.*@@' && \
60+
sed -E "${sedcomm}" containerd.service > buildkit.service && \
61+
echo "" >> buildkit.service && \
62+
echo "# This file was converted from containerd.service, with \`sed -E '${sedcomm}'\`" >> buildkit.service
5563
ARG STARGZ_SNAPSHOTTER_VERSION
5664
RUN curl -L https://github.com/containerd/stargz-snapshotter/releases/download/v${STARGZ_SNAPSHOTTER_VERSION}/stargz-snapshotter-v${STARGZ_SNAPSHOTTER_VERSION}-linux-${TARGETARCH:-amd64}.tar.gz | tar xzvC /out/bin && \
65+
curl -L -o /out/lib/systemd/system/stargz-snapshotter.service https://raw.githubusercontent.com/containerd/stargz-snapshotter/v${STARGZ_SNAPSHOTTER_VERSION}/script/config/etc/systemd/system/stargz-snapshotter.service && \
5766
echo "- Stargz Snapshotter: v${STARGZ_SNAPSHOTTER_VERSION}" >> /out/share/doc/nerdctl-full/README.md
5867
ARG ROOTLESSKIT_VERSION
5968
RUN curl -L https://github.com/rootless-containers/rootlesskit/releases/download/v${ROOTLESSKIT_VERSION}/rootlesskit-$(uname -m).tar.gz | tar xzvC /out/bin && \
@@ -74,19 +83,23 @@ FROM scratch AS out-full
7483
COPY --from=build-full /out /
7584

7685
FROM ubuntu:${UBUNTU_VERSION} AS base
86+
# fuse3 is required by stargz snapshotter
7787
RUN apt-get update && \
7888
apt-get install -qq -y --no-install-recommends \
7989
ca-certificates curl \
8090
iproute2 iptables \
81-
dbus systemd systemd-sysv
91+
dbus systemd systemd-sysv \
92+
fuse3
8293
ARG CONTAINERIZED_SYSTEMD_VERSION
8394
RUN curl -L -o /docker-entrypoint.sh https://raw.githubusercontent.com/AkihiroSuda/containerized-systemd/v${CONTAINERIZED_SYSTEMD_VERSION}/docker-entrypoint.sh && \
8495
chmod +x /docker-entrypoint.sh
8596
COPY --from=out-full / /usr/local/
86-
COPY Dockerfile.d/*.service /etc/systemd/system
87-
RUN systemctl enable containerd buildkitd
97+
RUN perl -pi -e 's/multi-user.target/docker-entrypoint.target/g' /usr/local/lib/systemd/system/*.service && \
98+
systemctl enable containerd buildkit stargz-snapshotter
99+
COPY ./Dockerfile.d/etc_containerd_config.toml /etc/containerd/config.toml
88100
VOLUME /var/lib/containerd
89101
VOLUME /var/lib/buildkit
102+
VOLUME /var/lib/containerd-stargz-grpc
90103
VOLUME /var/lib/nerdctl
91104
ENTRYPOINT ["/docker-entrypoint.sh"]
92105
CMD ["bash"]

Dockerfile.d/buildkitd.service

-43
This file was deleted.

Dockerfile.d/containerd.service

-43
This file was deleted.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version = 2
2+
3+
# Enable stargz snapshotter
4+
[proxy_plugins]
5+
[proxy_plugins.stargz]
6+
type = "snapshot"
7+
address = "/run/containerd-stargz-grpc/containerd-stargz-grpc.sock"

0 commit comments

Comments
 (0)