How to assign a docker-machine host a static ip address

Boot2docker uses DHCP by default. Most solutions I found simply assign a static address and neglect to disable DHCP. Which led to the machine simply changing its ip address after some time.

This command line should take care of that:

cat <<EOF | docker-machine ssh docker-host sudo tee /var/lib/boot2docker/ > /dev/null
kill `more /var/run/`
ifconfig eth0 netmask broadcast up
ip route add default via

After creating that file on the host restart it and regenerate the client certificates:

docker-machine restart docker-host
docker-machine env docker-host
docker-machine regenerate-certs docker-host

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.