github.com/skippbox/kompose-origin@v0.0.0-20160524133224-16a9dca7bac2/script/.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_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-vfs}
    15  export DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true}
    16  
    17  # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G"
    18  storage_params=""
    19  if [ -n "$DOCKER_STORAGE_OPTS" ]; then
    20      IFS=','
    21      for i in ${DOCKER_STORAGE_OPTS}; do
    22          storage_params="--storage-opt $i $storage_params"
    23      done
    24      unset IFS
    25  fi
    26  
    27  if [ -z "$DOCKER_TEST_HOST" ]; then
    28      export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" # "pwd" tricks to make sure $DEST is an absolute path, not a relative one
    29      ( set -x; exec \
    30                    docker daemon --debug \
    31                    --host "$DOCKER_HOST" \
    32                    --storage-driver "$DOCKER_GRAPHDRIVER" \
    33                    --pidfile "$DEST/docker.pid" \
    34                    --userland-proxy="$DOCKER_USERLANDPROXY" \
    35                    $storage_params \
    36        &> "$DEST/docker.log"
    37      ) &
    38      # make sure that if the script exits unexpectedly, we stop this daemon we just started
    39      trap 'bundle .integration-daemon-stop' EXIT
    40  else
    41      export DOCKER_HOST="$DOCKER_TEST_HOST"
    42  fi
    43  
    44  # give it a second to come up so it's "ready"
    45  tries=5
    46  while ! docker version &> /dev/null; do
    47      (( tries-- ))
    48      if [ $tries -le 0 ]; then
    49          if [ -z "$DOCKER_HOST" ]; then
    50              echo >&2 "error: daemon failed to start"
    51              echo >&2 "  check $DEST/docker.log for details"
    52          else
    53              echo >&2 "error: daemon at $DOCKER_HOST fails to 'docker version':"
    54              docker version >&2 || true
    55          fi
    56          false
    57      fi
    58      sleep 2
    59  done
    60  
    61  docker version