github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/hack/make/run (about) 1 #!/usr/bin/env bash 2 3 set -e 4 rm -rf "$DEST" 5 6 if ! command -v dockerd &> /dev/null; then 7 echo >&2 'error: binary-daemon or dynbinary-daemon must be run before run' 8 false 9 fi 10 11 DOCKER_COMMAND="$(command -v dockerd)" 12 13 DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-vfs} 14 DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true} 15 16 # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G" 17 storage_params="" 18 if [ -n "$DOCKER_STORAGE_OPTS" ]; then 19 IFS=',' 20 for i in ${DOCKER_STORAGE_OPTS}; do 21 storage_params="--storage-opt $i $storage_params" 22 done 23 unset IFS 24 fi 25 26 listen_port=2375 27 if [ -n "$DOCKER_PORT" ]; then 28 listen_port="${DOCKER_PORT##*:}" 29 fi 30 31 if [ -n "$DELVE_PORT" ]; then 32 delve_listen_port="${DELVE_PORT##*:}" 33 fi 34 35 extra_params="$DOCKERD_ARGS" 36 if [ "$DOCKER_REMAP_ROOT" ]; then 37 extra_params="$extra_params --userns-remap $DOCKER_REMAP_ROOT" 38 fi 39 40 if [ -n "$DOCKER_EXPERIMENTAL" ]; then 41 extra_params="$extra_params --experimental" 42 fi 43 44 socket=/var/run/docker.sock 45 if [ -n "$DOCKER_ROOTLESS" ]; then 46 user="unprivilegeduser" 47 uid=$(id -u $user) 48 # shellcheck disable=SC2174 49 mkdir -p -m 700 "/tmp/docker-${uid}" 50 chown $user "/tmp/docker-${uid}" 51 socket=/tmp/docker-${uid}/docker.sock 52 fi 53 54 # shellcheck disable=SC2206 55 args=( 56 --debug 57 --host="tcp://0.0.0.0:${listen_port}" 58 --host="unix://${socket}" 59 --storage-driver="${DOCKER_GRAPHDRIVER}" 60 --userland-proxy="${DOCKER_USERLANDPROXY}" 61 --tls=false 62 $storage_params 63 $extra_params 64 ) 65 66 dockerd=("$DOCKER_COMMAND") 67 68 if [ -n "$DELVE_PORT" ]; then 69 dockerd=( 70 dlv 71 --listen="0.0.0.0:$delve_listen_port" 72 --headless=true 73 --log 74 --api-version=2 75 --only-same-user=false 76 --check-go-version=false 77 --accept-multiclient 78 exec "${dockerd[@]}" -- 79 ) 80 fi 81 82 if [ -n "$DOCKER_ROOTLESS" ]; then 83 dockerd=( 84 sudo -u "$user" 85 -E DOCKERD="${dockerd[*]}" 86 -E XDG_RUNTIME_DIR="/tmp/docker-${uid}" 87 -E XDG_CONFIG_HOME="/home/${user}/.config" 88 -E HOME="/home/${user}" 89 -- 90 dockerd-rootless.sh 91 ) 92 fi 93 94 set -x 95 # shellcheck disable=SC2086 96 exec "${dockerd[@]}" "${args[@]}"