diff bamboo-agent/docker-entrypoint.sh @ 264:3754be907d9b production vv2.1.0

flow: Merged <release> 'v2.1.0' to <master> ('production').
author aldrich@nwoca.org
date Thu, 26 Jul 2018 14:27:43 +0100
parents 3799d9706864
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bamboo-agent/docker-entrypoint.sh	Thu Jul 26 14:27:43 2018 +0100
@@ -0,0 +1,30 @@
+#!/bin/bash
+set -e
+
+# first arg is `-f` or `--some-option`
+if [ "${1#-}" != "$1" ]; then
+	set -- docker "$@"
+fi
+
+# if our command is a valid Docker subcommand, let's invoke it through Docker instead
+# (this allows for "docker run docker ps", etc)
+if docker help "$1" > /dev/null 2>&1; then
+	set -- docker "$@"
+fi
+
+# if we have "--link some-docker:docker" and not DOCKER_HOST, let's set DOCKER_HOST automatically
+if [ -z "$DOCKER_HOST" -a "$DOCKER_PORT_2375_TCP" ]; then
+	export DOCKER_HOST='tcp://docker:2375'
+fi
+
+if [ "$1" = 'dockerd' ]; then
+	cat >&2 <<-'EOW'
+		📎 Hey there!  It looks like you're trying to run a Docker daemon.
+		   You probably should use the "dind" image variant instead, something like:
+		     docker run --privileged --name some-overlay-docker -d docker:stable-dind --storage-driver=overlay
+		   See https://hub.docker.com/_/docker/ for more documentation and usage examples.
+	EOW
+	sleep 3
+fi
+
+exec "$@"