Skip to content

Instantly share code, notes, and snippets.

@dajulia3
Last active February 6, 2016 22:39
Show Gist options
  • Save dajulia3/07af7025f0a972cdbde2 to your computer and use it in GitHub Desktop.
Save dajulia3/07af7025f0a972cdbde2 to your computer and use it in GitHub Desktop.
How to make a private registry accessible from inside docker-machine
#NOTE: our ci machine currently has a weird pfctl rule that I put in place on friday, so port 5000 is not working.
#Remove that rule, and this should work.
docker-machine create --driver virtualbox --engine-insecure-registry ci:5000 default #Run on all agents/dev boxes
#THE BELOW LINES ONLY APPLY TO THE CI SERVER:
docker-machine stop default
vboxmanage modifyvm "default" --natpf1 "tcp-port5000,tcp,,5000,,5000";
docker-machine start default
docker-machine ssh default "sudo -- sh -c 'echo 10.0.2.2 ci >> /etc/hosts'"
#in the osx machine, change /etc/hosts file entry for 127.0.0.1 localhost to include the ci alias
#In conjunction with the virtualbox port forwarding, this makes it so code docker pushes to the private repo can work on the ci host machine
sed -i '' 's/.*127\.0\.0\.1.*localhost.*/127.0.0.1 localhost ci/' example-hostsfile
echo "on other machines, now use the ci machine's network address and put an entry into their /etc/hosts file. Problem solved!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment