Trying to set docker-machine to fixed IP, but it keeps changing back


I tried to fix my docker-machine vm to a fixed ip by following this: fixIP4dm

It was at first successful. But a while later, it gets changed back to the original, and I had to do the same again. If I delete and recreate it again, it ends up with, and the number keeps going up with every new creation, and that happens even after I kill the DHCP process.

I also tried to use the option --virtualbox-hostonly-cidr to fix the address as one suggested, though I don’t understand what that means.

docker-machine create -d virtualbox --virtualbox-hostonly-cidr=“” swarmmgr

But it doesn’t work at all gives this “Error creating machine: Error in driver during machine creation: Error setting up host only network on machine start: host-only cidr must be specified with a host address, not a network address”

Would anyone who has been been successful in setting a permanent fixed IP to a docker-machine VM share some experience and insight? or point out what I’m doing wrong.

thanks much!


you haven’t say if you’re on Linux and if it should be an IP on your host’s network.

If that is the case, then you can create a new Docker network using the macvlan driver and assigning fixed IPs in compose files. Works perfectly on Ubuntu.

Actually I use a script to create/remove such a network when I need it.

If that’s what you would need, I could publish the script on GitHub.


Hi Accetto,

thanks so much for sharing this!

Yes, I’m on Ubuntu 16.04. Will read about macvlan. It would be great if you can share the script that embodies your insight.

thanks a lot,

Sorry, I have trouble to spare time for preparing the script for publishing. But I’ve been inspired by this blog article:

Hopefully it helps.