github.com/afbjorklund/moby@v20.10.5+incompatible/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_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-vfs}
    12  DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true}
    13  
    14  # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G"
    15  storage_params=""
    16  if [ -n "$DOCKER_STORAGE_OPTS" ]; then
    17  	IFS=','
    18  	for i in ${DOCKER_STORAGE_OPTS}; do
    19  		storage_params="--storage-opt $i $storage_params"
    20  	done
    21  	unset IFS
    22  fi
    23  
    24  listen_port=2375
    25  if [ -n "$DOCKER_PORT" ]; then
    26  	IFS=':' read -r -a ports <<< "$DOCKER_PORT"
    27  	listen_port="${ports[-1]}"
    28  fi
    29  
    30  extra_params="$DOCKERD_ARGS"
    31  if [ "$DOCKER_REMAP_ROOT" ]; then
    32  	extra_params="$extra_params --userns-remap $DOCKER_REMAP_ROOT"
    33  fi
    34  
    35  if [ -n "$DOCKER_EXPERIMENTAL" ]; then
    36  	extra_params="$extra_params --experimental"
    37  fi
    38  
    39  dockerd="dockerd"
    40  socket=/var/run/docker.sock
    41  if [ -n "$DOCKER_ROOTLESS" ]; then
    42  	user="unprivilegeduser"
    43  	uid=$(id -u $user)
    44  	# shellcheck disable=SC2174
    45  	mkdir -p -m 700 "/tmp/docker-${uid}"
    46  	chown $user "/tmp/docker-${uid}"
    47  	dockerd="sudo -u $user -E XDG_RUNTIME_DIR=/tmp/docker-${uid} -E HOME=/home/${user} -- dockerd-rootless.sh"
    48  	socket=/tmp/docker-${uid}/docker.sock
    49  fi
    50  
    51  args="--debug \
    52  	--host "tcp://0.0.0.0:${listen_port}" --host "unix://${socket}" \
    53  	--storage-driver "${DOCKER_GRAPHDRIVER}" \
    54  	--userland-proxy="${DOCKER_USERLANDPROXY}" \
    55  	$storage_params \
    56  	$extra_params"
    57  
    58  echo "${dockerd} ${args}"
    59  # shellcheck disable=SC2086
    60  exec "${dockerd}" ${args}