Skip to content

Instantly share code, notes, and snippets.

@deizel
Created March 3, 2016 00:36
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 deizel/89fa6a08f7208600b79f to your computer and use it in GitHub Desktop.
Save deizel/89fa6a08f7208600b79f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
sudo route -n delete 172.17.0.0/16
sudo route -n add 172.17.0.0/16 local.docker
DOCKER_INTERFACE=$(route get local.docker | grep interface: | cut -f 2 -d: | tr -d ' ')
DOCKER_INTERFACE_MEMBERSHIP=$(ifconfig "${DOCKER_INTERFACE}" | grep member: | cut -f 2 -d: | cut -c 2-4)
if [ -z "$DOCKER_INTERFACE_MEMBERSHIP" ]; then
echo -e "Could not find 'member:' in \`ifconfig ${DOCKER_INTERFACE}\` output.\n"
echo -e "Try restarting \`dlite\`:\n"
echo -e " dlite stop && dlite start\n"
exit 1
fi
sudo ifconfig "${DOCKER_INTERFACE}" -hostfilter "${DOCKER_INTERFACE_MEMBERSHIP}"
DOCKER_CONTAINER_IP=$(docker inspect -f '{{.NetworkSettings.IPAddress}}' "$(docker ps -q | head -1)")
ping -c 1 "${DOCKER_CONTAINER_IP}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment