2017-02-13 19:01:54 +00:00
|
|
|
#!/usr/bin/env bash
|
2014-04-29 05:13:25 +00:00
|
|
|
set -e
|
2013-09-07 02:02:59 +00:00
|
|
|
|
2013-09-07 02:03:29 +00:00
|
|
|
# DinD: a wrapper script which allows docker to be run inside a docker container.
|
2014-07-24 22:19:50 +00:00
|
|
|
# Original version by Jerome Petazzoni <jerome@docker.com>
|
2015-04-11 17:22:16 +00:00
|
|
|
# See the blog post: https://blog.docker.com/2013/09/docker-can-now-run-within-docker/
|
2013-09-07 02:03:29 +00:00
|
|
|
#
|
2016-05-25 03:38:28 +00:00
|
|
|
# This script should be executed inside a docker container in privileged mode
|
2014-03-13 17:46:02 +00:00
|
|
|
# ('docker run --privileged', introduced in docker 0.6).
|
2013-09-07 02:03:29 +00:00
|
|
|
|
|
|
|
# Usage: dind CMD [ARG...]
|
|
|
|
|
2014-05-01 21:52:29 +00:00
|
|
|
# apparmor sucks and Docker needs to know that it's in a container (c) @tianon
|
|
|
|
export container=docker
|
|
|
|
|
2018-12-22 19:18:33 +00:00
|
|
|
if [[ -d /sys/kernel/security ]] && ! mountpoint -q /sys/kernel/security; then
|
2014-04-29 05:13:25 +00:00
|
|
|
mount -t securityfs none /sys/kernel/security || {
|
|
|
|
echo >&2 'Could not mount /sys/kernel/security.'
|
2015-10-12 05:46:14 +00:00
|
|
|
echo >&2 'AppArmor detection and --privileged mode might break.'
|
2014-04-29 05:13:25 +00:00
|
|
|
}
|
2013-10-31 21:58:43 +00:00
|
|
|
fi
|
|
|
|
|
2015-08-21 22:47:50 +00:00
|
|
|
# Mount /tmp (conditionally)
|
|
|
|
if ! mountpoint -q /tmp; then
|
|
|
|
mount -t tmpfs none /tmp
|
|
|
|
fi
|
2013-09-07 02:19:03 +00:00
|
|
|
|
2018-12-22 19:18:33 +00:00
|
|
|
if [[ $# -gt 0 ]]; then
|
2014-04-29 05:13:25 +00:00
|
|
|
exec "$@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo >&2 'ERROR: No command specified.'
|
|
|
|
echo >&2 'You probably want to run hack/make.sh, or maybe a shell?'
|