-
Notifications
You must be signed in to change notification settings - Fork 2
/
dind-setup.sh
47 lines (36 loc) · 1.26 KB
/
dind-setup.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
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
# Enable overlayfs for dind if it can be tested to work.
function enable-overlay-storage() {
local storage_dir=${1:-/var/lib/docker}
local msg=""
if grep -q overlay /proc/filesystems; then
# Smoke test the overlay filesystem:
# 1. create smoke dir in the storage dir being mounted
local d="${storage_dir}/smoke"
mkdir -p "${d}/upper" "${d}/lower" "${d}/work" "${d}/mount"
# 2. try to mount an overlay fs on top of the smoke dir
local overlay_works=1
mount -t overlay overlay\
-o"lowerdir=${d}/lower,upperdir=${d}/upper,workdir=${d}/work"\
"${d}/mount" &&\
# 3. try to write a file in the overlay mount
echo foo > "${d}/mount/probe" || overlay_works=
umount -f "${d}/mount" || true
rm -rf "${d}" || true
if [[ -n "${overlay_works}" ]]; then
msg="Enabling overlay storage for docker-in-docker"
sed -i -e 's+vfs+overlay+' /etc/sysconfig/docker-storage
fi
fi
if [[ -z "${msg}" ]]; then
msg="WARNING: Unable to enable overlay storage for docker-in-docker"
fi
echo "${msg}"
}
# Ensure shared mount propagation to ensure volume mounting works for
# Kubernetes and OpenShift.
mount --make-shared /
enable-overlay-storage