2017-02-13 11:01:54 -08:00
|
|
|
#!/usr/bin/env bash
|
2014-04-28 23:13:25 -06:00
|
|
|
set -e
|
2013-09-06 19:02:59 -07:00
|
|
|
|
2013-09-06 19:03:29 -07: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 13:22:16 -04:00
|
|
|
# See the blog post: https://blog.docker.com/2013/09/docker-can-now-run-within-docker/
|
2013-09-06 19:03:29 -07:00
|
|
|
#
|
2016-05-24 20:38:28 -07:00
|
|
|
# This script should be executed inside a docker container in privileged mode
|
2014-03-13 11:46:02 -06:00
|
|
|
# ('docker run --privileged', introduced in docker 0.6).
|
2013-09-06 19:03:29 -07: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
|
|
|
|
|
2014-04-28 23:13:25 -06:00
|
|
|
if [ -d /sys/kernel/security ] && ! mountpoint -q /sys/kernel/security; then
|
|
|
|
mount -t securityfs none /sys/kernel/security || {
|
|
|
|
echo >&2 'Could not mount /sys/kernel/security.'
|
2015-10-11 22:46:14 -07:00
|
|
|
echo >&2 'AppArmor detection and --privileged mode might break.'
|
2014-04-28 23:13:25 -06:00
|
|
|
}
|
2013-10-31 14:58:43 -07:00
|
|
|
fi
|
|
|
|
|
2015-08-21 15:47:50 -07:00
|
|
|
# Mount /tmp (conditionally)
|
|
|
|
if ! mountpoint -q /tmp; then
|
|
|
|
mount -t tmpfs none /tmp
|
|
|
|
fi
|
2013-09-06 19:19:03 -07:00
|
|
|
|
2014-04-28 23:13:25 -06:00
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
exec "$@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo >&2 'ERROR: No command specified.'
|
|
|
|
echo >&2 'You probably want to run hack/make.sh, or maybe a shell?'
|