github.com/wulonghui/docker@v1.8.0-rc2/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_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 # Start apparmor if it is enabled 31 if [ -e "/sys/module/apparmor/parameters/enabled" ] && [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then 32 # reset container variable so apparmor profile is applied to process 33 # see https://github.com/docker/libcontainer/blob/master/apparmor/apparmor.go#L16 34 export container="" 35 ( 36 set -x 37 /etc/init.d/apparmor start 38 39 /sbin/apparmor_parser -r -W -T contrib/apparmor/ 40 ) 41 fi 42 43 export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" # "pwd" tricks to make sure $DEST is an absolute path, not a relative one 44 ( set -x; exec \ 45 docker --daemon --debug \ 46 --host "$DOCKER_HOST" \ 47 --storage-driver "$DOCKER_GRAPHDRIVER" \ 48 --exec-driver "$DOCKER_EXECDRIVER" \ 49 --pidfile "$DEST/docker.pid" \ 50 --userland-proxy="$DOCKER_USERLANDPROXY" \ 51 $storage_params \ 52 &> "$DEST/docker.log" 53 ) & 54 # make sure that if the script exits unexpectedly, we stop this daemon we just started 55 trap 'bundle .integration-daemon-stop' EXIT 56 else 57 export DOCKER_HOST="$DOCKER_TEST_HOST" 58 fi 59 60 # give it a second to come up so it's "ready" 61 tries=10 62 while ! docker version &> /dev/null; do 63 (( tries-- )) 64 if [ $tries -le 0 ]; then 65 if [ -z "$DOCKER_HOST" ]; then 66 echo >&2 "error: daemon failed to start" 67 echo >&2 " check $DEST/docker.log for details" 68 else 69 echo >&2 "error: daemon at $DOCKER_HOST fails to 'docker version':" 70 docker version >&2 || true 71 fi 72 false 73 fi 74 sleep 2 75 done