docker-dind-fedora/dind-entrypoint.sh
XLion a62f086562
All checks were successful
build / docker (push) Successful in 14m13s
Update dind-entrypoint.sh
2026-08-04 23:09:54 +08:00

60 lines
1.8 KiB
Shell
Executable file

#!/usr/bin/bash
set -e
# Use dockerd as the default command.
if [[ "$#" -eq 0 ]]; then
set -- dockerd
elif [[ "$1" == -* ]]; then
set -- dockerd "$@"
fi
# DinD initialization is only required when starting dockerd.
if [[ "$1" == "dockerd" || "$1" == "/usr/bin/dockerd" ]]; then
# Inform container-aware components that they are running in a container.
export container=docker
# Make securityfs available for AppArmor-enabled hosts.
if [[ -d /sys/kernel/security ]] &&
! mountpoint -q /sys/kernel/security; then
mount -t securityfs none /sys/kernel/security || {
echo >&2 "warning: unable to mount securityfs; inner AppArmor support may be unavailable"
}
fi
# Prepare cgroup v2 for nested container cgroups.
if [[ -f /sys/fs/cgroup/cgroup.controllers ]]; then
mkdir -p /sys/fs/cgroup/init
while ! {
xargs -r -n1 \
< /sys/fs/cgroup/cgroup.procs \
> /sys/fs/cgroup/init/cgroup.procs 2>/dev/null
sed -e 's/ / +/g' -e 's/^/+/' \
< /sys/fs/cgroup/cgroup.controllers \
> /sys/fs/cgroup/cgroup.subtree_control
}; do
true
done
fi
# Allow nested container mounts to propagate correctly.
mount --make-rshared /
# Remove stale PID files left by an unclean shutdown.
rm -f \
/run/docker.pid \
/var/run/docker.pid \
/run/docker/containerd/containerd.pid
# Use the classic Docker image store with overlay2 by default.
# This could be removed if the newer storage driver backend fixed the write lock issues.
# set -- "$@" \
# --feature=containerd-snapshotter=false \
# --storage-driver=overlay2
exec /usr/libexec/docker/docker-init -- "$@"
fi
# Allow the image to run commands other than dockerd.
exec "$@"