Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save metacollin/c65638a68a75a62b884b8d7e664b1d15 to your computer and use it in GitHub Desktop.
Save metacollin/c65638a68a75a62b884b8d7e664b1d15 to your computer and use it in GitHub Desktop.

Revisions

  1. metacollin revised this gist Mar 29, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions make_docker_chooch.sh
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,10 @@
    # software defined network where containers created via boot2docker
    # reside. This lets you casually directly to ports (ssh, http, etc. etc.)
    # on those containers.
    #
    function ohfk(){ echo "FUCK: $*" ; }
    function ohno(){ echo "FAILING: $*" ; exit 1; }
    [ ! -z "$1" ] && DOCKER_MACHINE_ID="$1" || DOCKER_MACHINE_ID="default"

    DOCKER_MACHINE_ID=$1
    IP_OF_DOCKER_HOST=$(docker-machine ip $DOCKER_MACHINE_ID)
  2. metacollin revised this gist Mar 29, 2019. 2 changed files with 20 additions and 19 deletions.
    19 changes: 0 additions & 19 deletions establish-routing-to-docker-osx-container-network
    Original file line number Diff line number Diff line change
    @@ -1,19 +0,0 @@
    #!/bin/bash
    # Script to instruct the Mac how to route packets to the
    # software defined network where containers created via boot2docker
    # reside. This lets you casually directly to ports (ssh, http, etc. etc.)
    # on those containers.
    function ERROR(){ echo "ERROR: $*" ; }
    function FAIL(){ echo "FAILING: $*" ; exit 1; }

    IP_OF_DOCKER_HOST="172.16.42.43"
    SDN_NET_FOR_CONTAINERS=$(docker-osx ssh -c 'ip route show' 2> /dev/null | awk '/docker0/{print $1}' )
    echo "Establishing route to $SDN_NET_FOR_CONTAINERS via $IP_OF_DOCKER_HOST"
    if netstat -rn | awk "\$2 == \"$IP_OF_DOCKER_HOST\" {exit(1);}" ; then
    sudo route -n add "$SDN_NET_FOR_CONTAINERS" "$IP_OF_DOCKER_HOST"
    else
    ERROR "Already routing something to the docker VM ..."
    netstat -rn \
    | awk '$2 == "192.168.59.103"||/Destination.*Refs/{print;}'
    FAIL "... so never mind."
    fi
    20 changes: 20 additions & 0 deletions make_docker_chooch.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/bin/bash
    # Script to instruct the Mac how to route packets to the
    # software defined network where containers created via boot2docker
    # reside. This lets you casually directly to ports (ssh, http, etc. etc.)
    # on those containers.
    function ohfk(){ echo "FUCK: $*" ; }
    function ohno(){ echo "FAILING: $*" ; exit 1; }

    DOCKER_MACHINE_ID=$1
    IP_OF_DOCKER_HOST=$(docker-machine ip $DOCKER_MACHINE_ID)
    DOCKER_ROUTE_TO_SADNESS=$(docker-machine ssh $DOCKER_MACHINE_ID 'ip route show' 2> /dev/null | awk '/docker0/{print $1}' )
    echo "Establishing route to $DOCKER_ROUTE_TO_SADNESS via $IP_OF_DOCKER_HOST"
    if netstat -rn | awk "\$2 == \"$IP_OF_DOCKER_HOST\" {exit(1);}" ; then
    sudo route -n add "$DOCKER_ROUTE_TO_SADNESS" "$IP_OF_DOCKER_HOST"
    else
    ohfk "Already routing something to the docker VM ..."
    netstat -rn \
    | awk '$2 == "192.168.59.103"||/Destination.*Refs/{print;}'
    ohno "You stupid bitch."
    fi
  3. @fntlnz fntlnz renamed this gist Jul 29, 2014. 1 changed file with 0 additions and 0 deletions.
  4. @fntlnz fntlnz revised this gist Jul 29, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion establish-routing-to-boot2docker-container-network
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ function ERROR(){ echo "ERROR: $*" ; }
    function FAIL(){ echo "FAILING: $*" ; exit 1; }

    IP_OF_DOCKER_HOST="172.16.42.43"
    SDN_NET_FOR_CONTAINERS=$(boot2docker ssh ip route show 2> /dev/null | awk '/docker0/{print $1}' )
    SDN_NET_FOR_CONTAINERS=$(docker-osx ssh -c 'ip route show' 2> /dev/null | awk '/docker0/{print $1}' )
    echo "Establishing route to $SDN_NET_FOR_CONTAINERS via $IP_OF_DOCKER_HOST"
    if netstat -rn | awk "\$2 == \"$IP_OF_DOCKER_HOST\" {exit(1);}" ; then
    sudo route -n add "$SDN_NET_FOR_CONTAINERS" "$IP_OF_DOCKER_HOST"
  5. @fntlnz fntlnz revised this gist Jul 29, 2014. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions establish-routing-to-boot2docker-container-network
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,8 @@
    # on those containers.
    function ERROR(){ echo "ERROR: $*" ; }
    function FAIL(){ echo "FAILING: $*" ; exit 1; }
    if [[ 'running' != $(boot2docker status) ]]
    then FAIL "boot2docker's VM not running" ; fi
    IP_OF_DOCKER_HOST=$(boot2docker ip 2> /dev/null)

    IP_OF_DOCKER_HOST="172.16.42.43"
    SDN_NET_FOR_CONTAINERS=$(boot2docker ssh ip route show 2> /dev/null | awk '/docker0/{print $1}' )
    echo "Establishing route to $SDN_NET_FOR_CONTAINERS via $IP_OF_DOCKER_HOST"
    if netstat -rn | awk "\$2 == \"$IP_OF_DOCKER_HOST\" {exit(1);}" ; then
  6. @bhyde bhyde revised this gist Jul 7, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion establish-routing-to-boot2docker-container-network
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    #!/bin/bash
    # Script to instruct the Mac how to route packets to the
    # software defined network where containers created via boot2docker
    # reside. This lets you casually directly to ports on those containers.
    # reside. This lets you casually directly to ports (ssh, http, etc. etc.)
    # on those containers.
    function ERROR(){ echo "ERROR: $*" ; }
    function FAIL(){ echo "FAILING: $*" ; exit 1; }
    if [[ 'running' != $(boot2docker status) ]]
  7. @bhyde bhyde created this gist Jul 7, 2014.
    19 changes: 19 additions & 0 deletions establish-routing-to-boot2docker-container-network
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/bin/bash
    # Script to instruct the Mac how to route packets to the
    # software defined network where containers created via boot2docker
    # reside. This lets you casually directly to ports on those containers.
    function ERROR(){ echo "ERROR: $*" ; }
    function FAIL(){ echo "FAILING: $*" ; exit 1; }
    if [[ 'running' != $(boot2docker status) ]]
    then FAIL "boot2docker's VM not running" ; fi
    IP_OF_DOCKER_HOST=$(boot2docker ip 2> /dev/null)
    SDN_NET_FOR_CONTAINERS=$(boot2docker ssh ip route show 2> /dev/null | awk '/docker0/{print $1}' )
    echo "Establishing route to $SDN_NET_FOR_CONTAINERS via $IP_OF_DOCKER_HOST"
    if netstat -rn | awk "\$2 == \"$IP_OF_DOCKER_HOST\" {exit(1);}" ; then
    sudo route -n add "$SDN_NET_FOR_CONTAINERS" "$IP_OF_DOCKER_HOST"
    else
    ERROR "Already routing something to the docker VM ..."
    netstat -rn \
    | awk '$2 == "192.168.59.103"||/Destination.*Refs/{print;}'
    FAIL "... so never mind."
    fi