Skip to content

Instantly share code, notes, and snippets.

@timhberry
Created June 20, 2018 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timhberry/20388eb8db878710cc2b53b7145a381e to your computer and use it in GitHub Desktop.
Save timhberry/20388eb8db878710cc2b53b7145a381e to your computer and use it in GitHub Desktop.
#!/bin/sh
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
exec "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment