github.com/hustcat/docker@v1.3.3-0.20160314103604-901c67a8eeab/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_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true} 17 18 # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G" 19 storage_params="" 20 if [ -n "$DOCKER_STORAGE_OPTS" ]; then 21 IFS=',' 22 for i in ${DOCKER_STORAGE_OPTS}; do 23 storage_params="--storage-opt $i $storage_params" 24 done 25 unset IFS 26 fi 27 28 # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G" 29 extra_params="" 30 if [ "$DOCKER_REMAP_ROOT" ]; then 31 extra_params="--userns-remap $DOCKER_REMAP_ROOT" 32 fi 33 34 if [ -z "$DOCKER_TEST_HOST" ]; then 35 # Start apparmor if it is enabled 36 if [ -e "/sys/module/apparmor/parameters/enabled" ] && [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then 37 # reset container variable so apparmor profile is applied to process 38 # see https://github.com/docker/libcontainer/blob/master/apparmor/apparmor.go#L16 39 export container="" 40 ( 41 set -x 42 /etc/init.d/apparmor start 43 ) 44 fi 45 46 export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" # "pwd" tricks to make sure $DEST is an absolute path, not a relative one 47 ( set -x; exec \ 48 docker daemon --debug \ 49 --host "$DOCKER_HOST" \ 50 --storage-driver "$DOCKER_GRAPHDRIVER" \ 51 --pidfile "$DEST/docker.pid" \ 52 --userland-proxy="$DOCKER_USERLANDPROXY" \ 53 $storage_params \ 54 $extra_params \ 55 &> "$DEST/docker.log" 56 ) & 57 # make sure that if the script exits unexpectedly, we stop this daemon we just started 58 trap 'bundle .integration-daemon-stop' EXIT 59 else 60 export DOCKER_HOST="$DOCKER_TEST_HOST" 61 fi 62 63 # give it a little time to come up so it's "ready" 64 tries=60 65 echo "INFO: Waiting for daemon to start..." 66 while ! docker version &> /dev/null; do 67 (( tries-- )) 68 if [ $tries -le 0 ]; then 69 printf "\n" 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 # Additional Windows CI debugging as this is a common error as of 77 # January 2016 78 if [ "$(go env GOOS)" = 'windows' ]; then 79 echo >&2 "Container log below:" 80 echo >&2 "---" 81 # Important - use the docker on the CI host, not the one built locally 82 # which is currently in our path. 83 ! /c/bin/docker -H=$MAIN_DOCKER_HOST logs docker-$COMMITHASH 84 echo >&2 "---" 85 fi 86 fi 87 false 88 fi 89 printf "." 90 sleep 2 91 done 92 printf "\n"