This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# Usage: ./docker-local-hosts.sh containername mylocalname | |
# Get IP of container and strip newlines. | |
INSPECT=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $1) | |
IP=${INSPECT//[$'\t\r\n']} | |
if test -z "$IP"; then | |
echo "Container IP for $1 not found." | |
exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# PATH TO YOUR HOSTS FILE | |
ETC_HOSTS=/etc/hosts | |
# DEFAULT IP FOR HOSTNAME | |
IP="127.0.0.1" | |
# Hostname to add/remove. | |
HOSTNAME=$1 |