github.com/click2cloud/libcompose@v0.4.1-0.20170816121048-7c20f79ac6b9/hack/.integration-daemon-start (about) 1 #!/bin/bash 2 # see test-integration-cli for example usage of this script 3 4 export PATH="$ABS_DEST/../binary:/usr/local/bin/docker-${DOCKER_DAEMON_VERSION}:$PATH" 5 6 if ! command -v docker &> /dev/null; then 7 echo >&2 'error: docker binary should be present to be able to run test-integration' 8 false 9 fi 10 11 # intentionally open a couple bogus file descriptors to help test that they get scrubbed in containers 12 exec 41>&1 42>&2 13 14 export DOCKER_GRAPH=/var/lib/docker/${DOCKER_DAEMON_VERSION} 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 dockerd=dockerd 29 command -v dockerd || { 30 dockerd="docker daemon" 31 } 32 33 if [ -z "$DOCKER_TEST_HOST" ]; then 34 export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" # "pwd" tricks to make sure $DEST is an absolute path, not a relative one 35 ( set -x; exec \ 36 $dockerd --debug \ 37 --host "$DOCKER_HOST" \ 38 --storage-driver "$DOCKER_GRAPHDRIVER" \ 39 --pidfile "$DEST/docker.pid" \ 40 --userland-proxy="$DOCKER_USERLANDPROXY" \ 41 --graph="$DOCKER_GRAPH" \ 42 $storage_params \ 43 &> "$DEST/docker.log" 44 ) & 45 # make sure that if the script exits unexpectedly, we stop this daemon we just started 46 trap 'bundle .integration-daemon-stop' EXIT 47 else 48 export DOCKER_HOST="$DOCKER_TEST_HOST" 49 fi 50 51 # give it a second to come up so it's "ready" 52 tries=5 53 while ! docker version &> /dev/null; do 54 (( tries-- )) 55 if [ $tries -le 0 ]; then 56 if [ -z "$DOCKER_HOST" ]; then 57 echo >&2 "error: daemon failed to start" 58 echo >&2 " check $DEST/docker.log for details" 59 else 60 echo >&2 "error: daemon at $DOCKER_HOST fails to 'docker version':" 61 docker version >&2 || true 62 fi 63 false 64 fi 65 sleep 2 66 done 67 68 docker version