github.com/shiroyuki/docker@v1.9.0/hack/make/.integration-daemon-start (about) 1 #!/bin/bash 2 3 # see test-integration-cli for example usage of this script 4 5 export PATH="$ABS_DEST/../binary:$ABS_DEST/../dynbinary:$ABS_DEST/../gccgo:$ABS_DEST/../dyngccgo:$PATH" 6 7 if ! command -v docker &> /dev/null; then 8 echo >&2 'error: binary or dynbinary must be run before .integration-daemon-start' 9 false 10 fi 11 12 # intentionally open a couple bogus file descriptors to help test that they get scrubbed in containers 13 exec 41>&1 42>&2 14 15 export DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-vfs} 16 export DOCKER_EXECDRIVER=${DOCKER_EXECDRIVER:-native} 17 export DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true} 18 19 # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G" 20 storage_params="" 21 if [ -n "$DOCKER_STORAGE_OPTS" ]; then 22 IFS=',' 23 for i in ${DOCKER_STORAGE_OPTS}; do 24 storage_params="--storage-opt $i $storage_params" 25 done 26 unset IFS 27 fi 28 29 # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G" 30 extra_params="" 31 if [ "$DOCKER_REMAP_ROOT" ]; then 32 extra_params="--userns-remap $DOCKER_REMAP_ROOT" 33 fi 34 35 if [ -z "$DOCKER_TEST_HOST" ]; then 36 # Start apparmor if it is enabled 37 if [ -e "/sys/module/apparmor/parameters/enabled" ] && [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then 38 # reset container variable so apparmor profile is applied to process 39 # see https://github.com/docker/libcontainer/blob/master/apparmor/apparmor.go#L16 40 export container="" 41 ( 42 set -x 43 /etc/init.d/apparmor start 44 ) 45 fi 46 47 export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" # "pwd" tricks to make sure $DEST is an absolute path, not a relative one 48 ( set -x; exec \ 49 docker daemon --debug \ 50 --host "$DOCKER_HOST" \ 51 --storage-driver "$DOCKER_GRAPHDRIVER" \ 52 --exec-driver "$DOCKER_EXECDRIVER" \ 53 --pidfile "$DEST/docker.pid" \ 54 --userland-proxy="$DOCKER_USERLANDPROXY" \ 55 $storage_params \ 56 $extra_params \ 57 &> "$DEST/docker.log" 58 ) & 59 # make sure that if the script exits unexpectedly, we stop this daemon we just started 60 trap 'bundle .integration-daemon-stop' EXIT 61 else 62 export DOCKER_HOST="$DOCKER_TEST_HOST" 63 fi 64 65 # give it a little time to come up so it's "ready" 66 tries=30 67 while ! docker version &> /dev/null; do 68 (( tries-- )) 69 if [ $tries -le 0 ]; then 70 if [ -z "$DOCKER_HOST" ]; then 71 echo >&2 "error: daemon failed to start" 72 echo >&2 " check $DEST/docker.log for details" 73 else 74 echo >&2 "error: daemon at $DOCKER_HOST fails to 'docker version':" 75 docker version >&2 || true 76 fi 77 false 78 fi 79 sleep 2 80 done