Skip to content

Instantly share code, notes, and snippets.

@rastaman
Created February 20, 2014 22:25
Show Gist options
  • Select an option

  • Save rastaman/9124578 to your computer and use it in GitHub Desktop.

Select an option

Save rastaman/9124578 to your computer and use it in GitHub Desktop.
Update apache proxys with ip of dockers containers
#!/bin/sh
sites_root=/etc/apache2/sites-available
docker ps | tail -n +2 | while read cid b; do
container_name=`docker inspect --format='{{.Config.Image}}' $cid`;
container_ip=`docker inspect --format='{{.NetworkSettings.IPAddress}}' $cid`;
if [ -f "$sites_root/${container_name}-docker" ] ; then
sed -i 's#^\(.*ProxyPass / http://\).*\(:.*\)$#\1'"${container_ip}"'\2#g' "$sites_root/${container_name}-docker"
sed -i 's#^\(.*ProxyPassReverse / http://\).*\(:.*\)$#\1'"${container_ip}"'\2#g' "$sites_root/${container_name}-docker"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment