Skip to content

Instantly share code, notes, and snippets.

@djdevin
djdevin / manage-etc-hosts.sh
Created February 21, 2019 15:49 — forked from irazasyed/manage-etc-hosts.sh
Bash Script to Manage /etc/hosts file for adding/removing hostnames.
#!/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
@djdevin
djdevin / docker-local-hosts.sh
Last active August 23, 2020 15:13
docker-local-hosts.sh
#!/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