Skip to content

Commit 214f70b

Browse files
author
OpenShift Bot
authored
Merge pull request #9661 from marun/dind-enable-overlay
Merged by openshift-bot
2 parents 4882c49 + 733e058 commit 214f70b

File tree

4 files changed

+40
-18
lines changed

4 files changed

+40
-18
lines changed

contrib/vagrant/provision-util.sh

+35-1
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,10 @@ os::provision::base-provision() {
209209
local origin_root=$1
210210
local is_master=${2:-false}
211211

212-
# Ensure that secrets can be correctly mounted for pods.
213212
if os::provision::in-container; then
213+
# Ensure that secrets can be correctly mounted for pods.
214214
mount --make-shared /
215+
os::provision::enable-overlay-storage
215216
fi
216217

217218
# Add a convenience symlink to the gopath repo
@@ -399,3 +400,36 @@ os::provision::wait-for-node-config() {
399400
os::provision::wait-for-condition "${msg}" "${condition}" \
400401
"${OS_WAIT_FOREVER}"
401402
}
403+
404+
# Enable overlayfs for dind if it can be tested to work.
405+
os::provision::enable-overlay-storage() {
406+
local storage_dir=${1:-/var/lib/docker}
407+
408+
local msg="WARNING: Unable to enable overlay storage for docker-in-docker"
409+
410+
if grep -q overlay /proc/filesystems; then
411+
# Smoke test the overlay filesystem:
412+
413+
# 1. create smoke dir in the storage dir being mounted
414+
local d="${storage_dir}/smoke"
415+
mkdir -p "${d}/upper" "${d}/lower" "${d}/work" "${d}/mount"
416+
417+
# 2. try to mount an overlay fs on top of the smoke dir
418+
local overlay_works=1
419+
mount -t overlay overlay\
420+
-o"lowerdir=${d}/lower,upperdir=${d}/upper,workdir=${d}/work"\
421+
"${d}/mount" &&\
422+
# 3. try to write a file in the overlay mount
423+
echo foo > "${d}/mount/probe" || overlay_works=
424+
425+
umount -f "${d}/mount" || true
426+
rm -rf "${d}" || true
427+
428+
if [[ -n "${overlay_works}" ]]; then
429+
msg="Enabling overlay storage for docker-in-docker"
430+
sed -i -e 's+vfs+overlay+' /etc/sysconfig/docker-storage
431+
fi
432+
fi
433+
434+
echo "${msg}"
435+
}

hack/dind-cluster.sh

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ function start() {
149149
sudo modprobe openvswitch
150150
sudo modprobe br_netfilter 2> /dev/null || true
151151
sudo sysctl -w net.bridge.bridge-nf-call-iptables=0 > /dev/null
152+
# overlayfs, if available, will be faster than vfs
153+
sudo modprobe overlay 2> /dev/null || true
152154
mkdir -p "${CONFIG_ROOT}"
153155

154156
if [[ "${SKIP_BUILD}" = "true" ]]; then

images/dind/Dockerfile

+3-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@ RUN dnf -y update && dnf -y install git golang hg tar make findutils \
4040
# sshd should be enabled as needed
4141
RUN systemctl disable sshd.service
4242

43-
## Configure dind
44-
ENV DIND_COMMIT 81aa1b507f51901eafcfaad70a656da376cf937d
45-
RUN curl -fL "https://raw.githubusercontent.com/docker/docker/${DIND_COMMIT}/hack/dind" \
46-
-o /usr/local/bin/dind && chmod +x /usr/local/bin/dind
47-
RUN mkdir -p /etc/systemd/system/docker.service.d
48-
COPY dind.conf /etc/systemd/system/docker.service.d/
43+
# Default storage to vfs. overlay will be enabled at runtime if available.
44+
RUN echo "DOCKER_STORAGE_OPTIONS=--storage-driver vfs" >\
45+
/etc/sysconfig/docker-storage
4946

5047
RUN systemctl enable docker
5148

images/dind/dind.conf

-11
This file was deleted.

0 commit comments

Comments
 (0)