Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Set DOCKER_HOST to use TCP to connect to daemon (#5)
Browse files Browse the repository at this point in the history
Set DOCKER_HOST to use TCP to connect to daemon
  • Loading branch information
rnorth authored Jul 30, 2019
2 parents d8229bd + a84ec08 commit d2732e7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export PLUGIN_CMD="sh -c '${PLUGIN_CMD}'"
echo "📦 Starting dind-drone-plugin"

echo "🐳 Starting docker-in-docker daemon"
/usr/local/bin/dockerd-entrypoint.sh dockerd --data-root /drone/docker -s ${PLUGIN_STORAGE_DRIVER:-vfs} --log-level error &
/usr/local/bin/dockerd-entrypoint.sh dockerd \
--data-root /drone/docker \
-s ${PLUGIN_STORAGE_DRIVER:-vfs} \
--log-level error \
-H tcp://0.0.0.0:2375 \
-H unix:///var/run/docker.sock &

for i in $(seq 1 30); do
echo "⏳ Pinging docker daemon ($i/30)"
Expand Down Expand Up @@ -61,6 +66,15 @@ for k in $(compgen -e); do
echo $k=${!k} >> ${PWD}/outer_env_vars.env
done

# Determine IP address at which dockerd and spawned containers can be reached
DOCKER_IP=$(ip route | awk '/docker0/ { print $7 }')
echo "DOCKER_HOST=tcp://${DOCKER_IP}:2375" >> ${PWD}/outer_env_vars.env
echo "ℹ️ Docker daemon will be available in the build container:"
echo " at /var/run/docker.sock"
echo " at tcp://${DOCKER_IP}:2375 (no TLS)"
echo "ℹ️ DOCKER_HOST will be set to tcp://${DOCKER_IP}:2375"
echo "ℹ️ Containers spawned by the build container will be accessible at ${DOCKER_IP} (do not hardcode this value)"

echo -e "\n\n"
MSG="🚀 About to run command: ${PLUGIN_CMD} on image ${PLUGIN_BUILD_IMAGE} inside Docker-in-Docker"
echo -e $MSG
Expand All @@ -82,6 +96,8 @@ CMD_EXIT_CODE=$?
echo; echo
echo "🏁 Exit code: $CMD_EXIT_CODE"

rm outer_env_vars.env

mkdir -p $IMAGE_CACHE_DIR
docker image prune -f
echo "💾 Exporting docker images to cache ($IMAGE_CACHE_DIR)"
Expand Down

0 comments on commit d2732e7

Please sign in to comment.