github.com/squaremo/docker@v1.3.2-0.20150516120342-42cfc9554972/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 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 if [ -z "$DOCKER_TEST_HOST" ]; then 30 export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" # "pwd" tricks to make sure $DEST is an absolute path, not a relative one 31 ( set -x; exec \ 32 docker --daemon --debug \ 33 --host "$DOCKER_HOST" \ 34 --storage-driver "$DOCKER_GRAPHDRIVER" \ 35 --exec-driver "$DOCKER_EXECDRIVER" \ 36 --pidfile "$DEST/docker.pid" \ 37 --userland-proxy="$DOCKER_USERLANDPROXY" \ 38 $storage_params \ 39 &> "$DEST/docker.log" 40 ) & 41 trap "source '${MAKEDIR}/.integration-daemon-stop'" EXIT # make sure that if the script exits unexpectedly, we stop this daemon we just started 42 else 43 export DOCKER_HOST="$DOCKER_TEST_HOST" 44 fi 45 46 # give it a second to come up so it's "ready" 47 tries=10 48 while ! docker version &> /dev/null; do 49 (( tries-- )) 50 if [ $tries -le 0 ]; then 51 if [ -z "$DOCKER_HOST" ]; then 52 echo >&2 "error: daemon failed to start" 53 echo >&2 " check $DEST/docker.log for details" 54 else 55 echo >&2 "error: daemon at $DOCKER_HOST fails to 'docker version':" 56 docker version >&2 || true 57 fi 58 false 59 fi 60 sleep 2 61 done