github.com/skf/moby@v1.13.1/hack/dind (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  # DinD: a wrapper script which allows docker to be run inside a docker container.
     5  # Original version by Jerome Petazzoni <jerome@docker.com>
     6  # See the blog post: https://blog.docker.com/2013/09/docker-can-now-run-within-docker/
     7  #
     8  # This script should be executed inside a docker container in privileged mode
     9  # ('docker run --privileged', introduced in docker 0.6).
    10  
    11  # Usage: dind CMD [ARG...]
    12  
    13  # apparmor sucks and Docker needs to know that it's in a container (c) @tianon
    14  export container=docker
    15  
    16  if [ -d /sys/kernel/security ] && ! mountpoint -q /sys/kernel/security; then
    17  	mount -t securityfs none /sys/kernel/security || {
    18  		echo >&2 'Could not mount /sys/kernel/security.'
    19  		echo >&2 'AppArmor detection and --privileged mode might break.'
    20  	}
    21  fi
    22  
    23  # Mount /tmp (conditionally)
    24  if ! mountpoint -q /tmp; then
    25  	mount -t tmpfs none /tmp
    26  fi
    27  
    28  if [ $# -gt 0 ]; then
    29  	exec "$@"
    30  fi
    31  
    32  echo >&2 'ERROR: No command specified.'
    33  echo >&2 'You probably want to run hack/make.sh, or maybe a shell?'