-
Notifications
You must be signed in to change notification settings - Fork 597
/
Dockerfile-dind.template
93 lines (84 loc) · 2.72 KB
/
Dockerfile-dind.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{{ include "shared" -}}
FROM docker:{{ env.version }}-cli
# https://github.com/moby/moby/blob/0eecd59153c03ced5f5ddd79cc98f29e4d86daec/project/PACKAGERS.md#runtime-dependencies
# https://github.com/docker/docker-ce-packaging/blob/963aa02666035d4e268f33c63d7868d6cdd1d34c/deb/common/control#L28-L41
RUN set -eux; \
apk add --no-cache \
btrfs-progs \
e2fsprogs \
e2fsprogs-extra \
git \
ip6tables \
iptables \
openssl \
pigz \
shadow-uidmap \
xfsprogs \
xz \
zfs \
;
# dind might be used on systems where the nf_tables kernel module isn't available. In that case,
# we need to switch over to xtables-legacy. See https://github.com/docker-library/docker/issues/463
RUN set -eux; \
apk add --no-cache iptables-legacy; \
# set up a symlink farm we can use PATH to switch to legacy with
mkdir -p /usr/local/sbin/.iptables-legacy; \
# https://gitlab.alpinelinux.org/alpine/aports/-/blob/a7e1610a67a46fc52668528efe01cee621c2ba6c/main/iptables/APKBUILD#L77
for f in \
iptables \
iptables-save \
iptables-restore \
ip6tables \
ip6tables-save \
ip6tables-restore \
; do \
# "iptables-save" -> "iptables-legacy-save", "ip6tables" -> "ip6tables-legacy", etc.
# https://pkgs.alpinelinux.org/contents?branch=v3.21&name=iptables-legacy&arch=x86_64
b="$(command -v "${f/tables/tables-legacy}")"; \
"$b" --version; \
ln -svT "$b" "/usr/local/sbin/.iptables-legacy/$f"; \
done; \
# verify it works (and gets us legacy)
export PATH="/usr/local/sbin/.iptables-legacy:$PATH"; \
iptables --version | grep legacy
# set up subuid/subgid so that "--userns-remap=default" works out-of-the-box
RUN set -eux; \
addgroup -S dockremap; \
adduser -S -G dockremap dockremap; \
echo 'dockremap:165536:65536' >> /etc/subuid; \
echo 'dockremap:165536:65536' >> /etc/subgid
RUN set -eux; \
\
{{
download({
arches: .arches,
urlKey: "dockerUrl",
# TODO sha256Key (once Docker publishes them 😭)
target: "docker.tgz",
})
}}; \
\
tar --extract \
--file docker.tgz \
--strip-components 1 \
--directory /usr/local/bin/ \
--no-same-owner \
# we exclude the CLI binary because we already extracted that over in the "docker:{{ env.version }}-cli" image that we're FROM and we don't want to duplicate those bytes again in this layer
--exclude 'docker/docker' \
; \
rm docker.tgz; \
\
dockerd --version; \
containerd --version; \
ctr --version; \
runc --version
# https://github.com/docker/docker/tree/master/hack/dind
ENV DIND_COMMIT {{ .dindCommit }}
RUN set -eux; \
wget -O /usr/local/bin/dind "https://raw.githubusercontent.com/docker/docker/${DIND_COMMIT}/hack/dind"; \
chmod +x /usr/local/bin/dind
COPY dockerd-entrypoint.sh /usr/local/bin/
VOLUME /var/lib/docker
EXPOSE 2375 2376
ENTRYPOINT ["dockerd-entrypoint.sh"]
CMD []