Reputation: 51
I ran the command, brew services start docker-machine
.
It says, "Successfully started docker-machine
". But, I got error when I ran docker ps -a
. Please help.
brew services start docker-machine
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 1488, done.
remote: Counting objects: 100% (367/367), done.
remote: Compressing objects: 100% (266/266), done.
remote: Total 1488 (delta 148), reused 267 (delta 93), pack-reused 1121
Receiving objects: 100% (1488/1488), 437.97 KiB | 3.04 MiB/s, done.
Resolving deltas: 100% (624/624), done.
Tapped 1 command (38 files, 540.5KB).
==> Successfully started `docker-machine` (label: homebrew.mxcl.docker-machine)
% docker ps -a
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
docker-machine create --driver virtualbox default
gives me the following errors:
docker-machine create --driver virtualbox default
Running pre-create checks...
(default) Image cache directory does not exist, creating it at /Users/perryluo/.docker/machine/cache...
(default) No default Boot2Docker ISO found locally, downloading the latest release...
(default) Latest release for github.com/boot2docker/boot2docker is v19.03.12
(default) Downloading /Users/perryluo/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v19.03.12/boot2docker.iso...
(default) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(default) Copying /Users/perryluo/.docker/machine/cache/boot2docker.iso to /Users/perryluo/.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
$ sudo docker-machine create --driver virtualbox default
Docker machine "default" already exists
$ docker-machine stop default
Stopping "default"...
Machine "default" is already stopped.
$ docker-machine start default
Starting "default"...
(default) Check network to re-create if needed...
(default) Found a new host-only adapter: "vboxnet2"
Error setting up host only network on machine start: /usr/local/bin/VBoxManage hostonlyif ipconfig vboxnet2 --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
$ docker-machine env default
Error checking TLS connection: Host is not running
Upvotes: 4
Views: 15217
Reputation: 251
Same problem here. I have found that docker-machine
is trying to move its HostOnly
network
to 192.168.99.1/24
. This is outside the range VirtualBox allows on MacOS.
See https://www.virtualbox.org/manual/ch06.html#network_hostonly :
On Linux, Mac OS X and Solaris, Oracle VM VirtualBox will only allow IP addresses in the
192.168.56.0/21
range to be assigned to host-only adapters.
That range corresponds to 192.168.56.1
- 192.168.63.255
.
The solution that worked for me is:
docker-machine rm default
docker-machine create -d virtualbox --virtualbox-hostonly-cidr "192.168.63.1/24" default
Upvotes: 15
Reputation: 2584
You're starting docker-machine
as a service but not any Docker Socket.
Once you have installed docker
and docker-machine
with brew
, you actually need to run Docker on a Linux kernel, docker
binary is just the client and you cannot run Docker natively in OS X.
So first, you need to create a machine with VirtualBox where you're actually going to run Docker. For that you should do:
docker-machine create --driver virtualbox default
In case that you receive an error like:
Running pre-create checks...
Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"
That means that you don't have Virtual Box installed, so you need to cask
-install it on your MacBook:
brew install virtualbox --cask
Once you have already installed VirtualBox, it's time to create a machine with the aforementioned command. You should have an output like the following:
docker-machine create --driver virtualbox default
[...]
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env default
But still if you run docker ps
or similar it will complain that the Socket isn't running. The reason is that Docker CLI looks by default for the local daemon, so we have to explicitly tell the CLI that we want to use a different one.
For that, run the following command that will tell your CLI which machine do we actually want to use:
docker-machine env default
Next time you run docker ps
or any other Docker command, it will work and run on the created default
machine.
PD: Remember to stop the machine when you're not using it! For that you can just use the following command:
docker-machine stop default
Did everything before sounded like a lot of work and you just want to use Docker now without any further work?
Install it as an application and forget about docker-machine
:
brew cask install docker
That's it.
Upvotes: 2