Created
June 12, 2014 09:02
-
-
Save svenwltr/ac6f611acbb3004561c0 to your computer and use it in GitHub Desktop.
A transient HTTPD with docker.
This file contains 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 | |
VOLUME=$( readlink -f $1 ) | |
CID_FILE=$( mktemp -u ) | |
docker run --cidfile="${CID_FILE}" --rm=true -v "${VOLUME}:/usr/local/nginx/html:ro" nginx & | |
while [ ! -f $CID_FILE ] ; | |
do | |
sleep 1 | |
done | |
echo "" | |
echo "" | |
CID=$( cat ${CID_FILE} ) | |
rm ${CID_FILE} | |
IP=$( docker inspect ${CID} | jq --raw-output '.[0].NetworkSettings.IPAddress' ) | |
echo "--+" | |
echo " | URL: http://${IP}/" | |
echo "--+" | |
echo "" | |
echo "Press [Enter] key to stop container..." | |
echo "" | |
read | |
docker stop ${CID} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment