15

I have docker, docker-machine, and virtualbox installed using HomeBrew:

Docker version 20.10.11, build dea9396e18
docker-machine version 0.16.2, build bd45ab1
VBoxManage version 6.1.30r148432

when I try creating a new machine

docker-machine create -d virtualbox default

I get the below errors:

Running pre-create checks...
Creating machine...
(default) Copying /Users/foobar/.docker/machine/cache/boot2docker.iso to /Users/foobar/.docker/machine/machines/default/boot2docker.iso...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) Starting the VM...
(default) Check network to re-create if needed...
(default) Found a new host-only adapter: "vboxnet0"
Error creating machine: Error in driver during machine creation: Error setting up host only network on machine start: /usr/local/bin/VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.99.1 --netmask 255.255.255.0 failed:
VBoxManage: error: Code E_ACCESSDENIED (0x80070005) - Access denied (extended info not available)
VBoxManage: error: Context: "EnableStaticIPConfig(Bstr(pszIp).raw(), Bstr(pszNetmask).raw())" at line 242 of file VBoxManageHostonly.cpp

I have tried many things

  • reinstalling all of my packages
  • running the above command in sudo
  • using the kextload as instructed here to "enable kernel extensions"
  • checking if there are any orphaned machines from past as suggested here with docker-machine ls

to no avail. Apparently the issue is caused by the IP restriction for Host-Only networks in the newer versions of VirtualBox. Some posts suggesting a manual edit of the VirtualBox's networks.conf file. But I can't find it on my machine, nor I know what I should change there!

P.S.1. Asked a follow-up question here on Reddit.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
  • Not sure what's causing this problem exactly but try downgrading to **VirtualBox 6.1.26** that might solve your problem. – Affes Salem Dec 08 '21 at 21:59
  • @AffésSalem rather not to that, unless a more canonical solution is found. I am thinking if/how I can edit the `networks.conf` file to extend the IP range, If just could find where it is located first! – Foad S. Farimani Dec 08 '21 at 22:02

1 Answers1

56

Thanks to this comment on Reddit, I was able to figure the issue out:

  1. find all the machines with docker-machine ls
  2. remove the ones you don't need with docker-machine rm -y <machineName>
  3. find all the "host-only ethernet adapters" with VBoxManage list hostonlyifs
  4. Remove the orphaned ones with VBoxManage hostonlyif remove <networkName>
  5. Create a vbox folder in the etc directory with sudo mkdir
  6. Create a file networks.conf in the vbox folder, for example by sudo touch
  7. place the below line there
* 0.0.0.0/0 ::/0
  1. create a new machine with docker-machine create -d virtualbox <machineName>
  2. Run the command eval $(docker-machine env <machineName>) to configure your shell

P.S.1. One major drawback of the above solution is that every time you start the docker machine with docker-machine start <machineName> It takes a lot of time on Waiting for an IP...

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
  • 3
    @fips your welcome. It took me 4-5 nights to figure this out. frustrating! – Foad S. Farimani Dec 10 '21 at 07:11
  • 2
    You don't need to delete the entire machine (thankfully!). Steps 3-7 followed by `docker-machine start` work for me. – Stu Dec 14 '21 at 10:39
  • @Stu in my case because I had a lot of trial and error, it was a mess. But if you only have one docker-machine and no orphaned "host-only ethernet adapters", it should be OK. – Foad S. Farimani Dec 14 '21 at 19:54
  • 2
    Docker-machine has been archived (basically deprecated). Docker no longer supports it and I wouldn't recommend using it for any new use cases. https://github.com/docker/machine – BMitch Dec 15 '21 at 20:48
  • 1
    @BMitch you may see [this page](https://github.com/docker/for-win/issues/2596#issuecomment-600145238) to know why I detest Docker Desktop. – Foad S. Farimani Dec 15 '21 at 20:56
  • Thank you, Foad and everyone am struggling with another issue here "unning pre-create checks... Error with pre-create check: "This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory" any help is welcome, I am on macOS (Monetary) Virtual box and Linux ubuntu-20 – cloudcop Aug 31 '22 at 22:35