github.com/guilhermebr/docker@v1.4.2-0.20150428121140-67da055cebca/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="$DEST/../binary:$DEST/../dynbinary:$DEST/../gccgo:$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 18 if [ -z "$DOCKER_TEST_HOST" ]; then 19 export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" # "pwd" tricks to make sure $DEST is an absolute path, not a relative one 20 ( set -x; exec \ 21 docker --daemon --debug \ 22 --host "$DOCKER_HOST" \ 23 --storage-driver "$DOCKER_GRAPHDRIVER" \ 24 --exec-driver "$DOCKER_EXECDRIVER" \ 25 --pidfile "$DEST/docker.pid" \ 26 &> "$DEST/docker.log" 27 ) & 28 trap "source '${MAKEDIR}/.integration-daemon-stop'" EXIT # make sure that if the script exits unexpectedly, we stop this daemon we just started 29 else 30 export DOCKER_HOST="$DOCKER_TEST_HOST" 31 fi 32 33 # give it a second to come up so it's "ready" 34 tries=10 35 while ! docker version &> /dev/null; do 36 (( tries-- )) 37 if [ $tries -le 0 ]; then 38 if [ -z "$DOCKER_HOST" ]; then 39 echo >&2 "error: daemon failed to start" 40 echo >&2 " check $DEST/docker.log for details" 41 else 42 echo >&2 "error: daemon at $DOCKER_HOST fails to 'docker version':" 43 docker version >&2 || true 44 fi 45 false 46 fi 47 sleep 2 48 done