github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/hack/make/.integration-daemon-start (about) 1 #!/bin/bash 2 3 # see test-integration-cli for example usage of this script 4 5 base="$ABS_DEST/.." 6 export PATH="$base/binary-client:$base/binary-daemon:$base/dynbinary-client:$base/dynbinary-daemon:$PATH" 7 8 if ! command -v docker &> /dev/null; then 9 echo >&2 'error: binary-client or dynbinary-client must be run before .integration-daemon-start' 10 false 11 fi 12 13 # This is a temporary hack for split-binary mode. It can be removed once 14 # https://github.com/docker/docker/pull/22134 is merged into docker master 15 if [ "$(go env GOOS)" = 'windows' ]; then 16 return 17 fi 18 19 if [ -z "$DOCKER_TEST_HOST" ]; then 20 if docker version &> /dev/null; then 21 echo >&2 'skipping daemon start, since daemon appears to be already started' 22 return 23 fi 24 fi 25 26 if ! command -v dockerd &> /dev/null; then 27 echo >&2 'error: binary-daemon or dynbinary-daemon must be run before .integration-daemon-start' 28 false 29 fi 30 31 # intentionally open a couple bogus file descriptors to help test that they get scrubbed in containers 32 exec 41>&1 42>&2 33 34 export DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-vfs} 35 export DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true} 36 37 # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G" 38 storage_params="" 39 if [ -n "$DOCKER_STORAGE_OPTS" ]; then 40 IFS=',' 41 for i in ${DOCKER_STORAGE_OPTS}; do 42 storage_params="--storage-opt $i $storage_params" 43 done 44 unset IFS 45 fi 46 47 # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G" 48 extra_params="" 49 if [ "$DOCKER_REMAP_ROOT" ]; then 50 extra_params="--userns-remap $DOCKER_REMAP_ROOT" 51 fi 52 53 if [ -z "$DOCKER_TEST_HOST" ]; then 54 # Start apparmor if it is enabled 55 if [ -e "/sys/module/apparmor/parameters/enabled" ] && [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then 56 # reset container variable so apparmor profile is applied to process 57 # see https://github.com/docker/libcontainer/blob/master/apparmor/apparmor.go#L16 58 export container="" 59 ( 60 set -x 61 /etc/init.d/apparmor start 62 ) 63 fi 64 65 export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" # "pwd" tricks to make sure $DEST is an absolute path, not a relative one 66 ( set -x; exec \ 67 dockerd --debug \ 68 --host "$DOCKER_HOST" \ 69 --storage-driver "$DOCKER_GRAPHDRIVER" \ 70 --pidfile "$DEST/docker.pid" \ 71 --userland-proxy="$DOCKER_USERLANDPROXY" \ 72 $storage_params \ 73 $extra_params \ 74 &> "$DEST/docker.log" 75 ) & 76 # make sure that if the script exits unexpectedly, we stop this daemon we just started 77 trap 'bundle .integration-daemon-stop' EXIT 78 else 79 export DOCKER_HOST="$DOCKER_TEST_HOST" 80 fi 81 82 # give it a little time to come up so it's "ready" 83 tries=60 84 echo "INFO: Waiting for daemon to start..." 85 while ! docker version &> /dev/null; do 86 (( tries-- )) 87 if [ $tries -le 0 ]; then 88 printf "\n" 89 if [ -z "$DOCKER_HOST" ]; then 90 echo >&2 "error: daemon failed to start" 91 echo >&2 " check $DEST/docker.log for details" 92 else 93 echo >&2 "error: daemon at $DOCKER_HOST fails to 'docker version':" 94 docker version >&2 || true 95 # Additional Windows CI debugging as this is a common error as of 96 # January 2016 97 if [ "$(go env GOOS)" = 'windows' ]; then 98 echo >&2 "Container log below:" 99 echo >&2 "---" 100 # Important - use the docker on the CI host, not the one built locally 101 # which is currently in our path. 102 ! /c/bin/docker -H=$MAIN_DOCKER_HOST logs docker-$COMMITHASH 103 echo >&2 "---" 104 fi 105 fi 106 false 107 fi 108 printf "." 109 sleep 2 110 done 111 printf "\n"