-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest-debs.sh
executable file
·103 lines (79 loc) · 3.03 KB
/
test-debs.sh
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
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
set -Eeuo pipefail
dist="$1"; shift
debs="$1"; shift
[ -d "$debs" ]
debs="$(readlink -ve "$debs")"
img="debian:$dist"
if ! docker image inspect --format '.' "$img" &> /dev/null; then
docker pull "$img"
fi
args=(
--interactive
--rm
--init
--name "test-moby-debs-$dist"
--mount "type=bind,src=$debs,dst=/debs,ro"
--privileged
--volume /var/lib/containerd
--volume /var/lib/docker
--tmpfs /run
)
if [ -t 0 ] && [ -t 1 ]; then
args+=( --tty )
fi
script="$(
cat <<-'EOBASH'
# https://github.com/moby/moby/blob/38805f20f9bcc5e87869d6c79d432b166e1c88b4/hack/dind#L28-L38
if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
mkdir -p /sys/fs/cgroup/init
xargs -rn1 < /sys/fs/cgroup/cgroup.procs > /sys/fs/cgroup/init/cgroup.procs || :
sed -e 's/ / +/g' -e 's/^/+/' < /sys/fs/cgroup/cgroup.controllers > /sys/fs/cgroup/cgroup.subtree_control
fi
apt-get update -qq
arch="$(dpkg --print-architecture)"
apt-get install -yqq --no-install-recommends -V ca-certificates iptables git /debs/moby-*_"${arch}".deb
containerd --version
ctr --version
docker --version
docker buildx version
runc --version
containerd & pid="$!"
timeout 10s sh -c "while ! ctr version; do sleep 1; done"
if ctr plugins ls | grep opt; then
exit 1
fi
ctr image pull docker.io/library/hello-world:latest
ctr run --rm docker.io/library/hello-world:latest hello
busybox='docker.io/library/busybox@sha256:5eef5ed34e1e1ff0a4ae850395cbf665c4de6b4b83a32a0bc7bcb998e24e7bbb' # "latest" as of 2024-05-25
ctr image pull "$busybox"
out="$(ctr run --rm --user 1000:1000 "$busybox" bb id)"
[ "$out" = 'uid=1000 gid=1000 groups=1000' ]
# stop "containerd" so dockerd can start it up and we can test the "dockerd starts/manages containerd" behavior
kill "$pid"
wait "$pid"
# TODO also clear out containerd state?
dockerd &
timeout 10s sh -c "while ! docker version; do sleep 1; done"
if ctr -a /run/docker/containerd/containerd.sock plugins ls | grep opt; then
exit 1
fi
docker run --rm hello-world
docker run --rm --init hello-world
printf 'FROM hello-world\nRUN ["/hello"]' | DOCKER_BUILDKIT=0 docker build --tag hello-build:classic -
DOCKER_BUILDKIT=0 docker build --tag hello-build:classic-git 'https://github.com/docker-library/hello-world.git#3fb6ebca4163bf5b9cc496ac3e8f11cb1e754aee:amd64/hello-world'
printf 'FROM hello-world\nRUN ["/hello"]' | docker buildx build --tag hello-build:buildkit -
docker buildx create --name tianon --node tianon --driver docker-container --driver-opt image=tianon/buildkit --bootstrap
printf 'FROM hello-world\nRUN ["/hello"]' | docker buildx build --builder tianon --tag hello-build:buildx -
docker buildx build --tag hello-build:buildx-git 'https://github.com/docker-library/hello-world.git#3fb6ebca4163bf5b9cc496ac3e8f11cb1e754aee:amd64/hello-world'
docker image inspect --format '.' \
hello-build:classic \
hello-build:classic-git \
hello-build:buildkit \
hello-build:buildx \
hello-build:buildx-git \
> /dev/null
docker images
EOBASH
)"
exec docker run "${args[@]}" "$img" bash -Eeuo pipefail -xc "$script"