Docker-Machine stuck on creating default - macos

I'm trying to start the default machine of Docker on Mac OSX.
Everytime i'm trying to start a new default machine by command:
docker-machine create --driver virtualbox default
of using Docker Quick Start Terminal It stucks on
(default) Creating SSH key...
This is the output:
Running pre-create checks...
Creating machine...
(default) Copying /Users/avivpaz/.docker/machine/cache/boot2docker.iso to /Users/avivpaz/.docker/machine/machines/default/boot2docker.iso...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
This is my OSX and Docker versions:
Mac 10.11.3
docker-machine version 0.6.0, build e27fb87

That seems to be followed by issue 2788 and more related to VirtualBox than docker machine.
Try and reboot the Mac, or make sure there is no VBox... process.

First, just delete the boot2docker.iso from ~/cache directory and once again restart the docker terminal. If will download the fresh latest boot2docker.iso and you are good to go.
If it's not working manually download the latest boot2docker.iso and place it into the above directory of cache
/Users/{user}/.docker/machine/cache/
$ ~/.docker/machine/cache
$ ls
boot2docker.iso
And, finally run to create an virtual machine,
docker-machine create --driver virtualbox default
And, again, you are good to go. Hope this helps.

Related

docker-machine unable to create a machine on macOS, VBoxManage returning E_ACCESSDENIED error

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.
Thanks to this comment on Reddit, I was able to figure the issue out:
find all the machines with docker-machine ls
remove the ones you don't need with docker-machine rm -y <machineName>
find all the "host-only ethernet adapters" with VBoxManage list hostonlyifs
Remove the orphaned ones with VBoxManage hostonlyif remove <networkName>
Create a vbox folder in the etc directory with sudo mkdir
Create a file networks.conf in the vbox folder, for example by sudo touch
place the below line there
* 0.0.0.0/0 ::/0
create a new machine with docker-machine create -d virtualbox <machineName>
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...

How to run "docker-machine create" in OS X?

I started Docker and am now following the tutorial, but for all I know I couldn't run the docker-machine command on OS X.
The documentation states that you run the following command to create a local virtual machine:
docker-machine create --driver virtualbox manager
However, this command doesn't work in OS X (11.6), with the following error:
Running pre-create checks...
Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"
I tried to install the virtualbox; however, another page clearly states that you must not install it on your local machine:
VirtualBox prior to version 4.3.30 must NOT be installed (it is incompatible with Docker for Mac)
Note: If your system does not satisfy these requirements, you can install Docker Toolbox, which uses Oracle VirtualBox instead of HyperKit.
So I only installed Docker for Mac and not virtualbox. So what am I missing here? The example page says you can run the tutorial on OS X, so I wonder how I can proceed...
You can follow along and run this example using Docker for Mac, Docker for Windows or Docker for Linux.
I had the same issue today and resolved it by installing VirtualBox as an additional step after installing Docker for Mac (I did so with brew install --cask virtualbox)
I don't recall having to do the extra install previously, but maybe I already had VirtualBox already installed because of another tool (like Vagrant). Anyway, this is explained in the Docker Machine documentation:
If you are using Docker for Mac
Docker for Mac uses HyperKit, a lightweight macOS virtualization
solution built on top of the Hypervisor.framework in macOS 10.10
Yosemite and higher.
Currently, there is no docker-machine create driver for HyperKit, so
you will use virtualbox driver to create local machines. (See the
Docker Machine driver for Oracle VirtualBox.) Note that you can run
both HyperKit and Oracle VirtualBox on the same system. To learn more,
see Docker for Mac vs. Docker Toolbox.
Make sure you have the latest VirtualBox correctly installed on your system (either as part of an earlier Toolbox install, or manual
install).
I had the same issue. At the same spot ;-)
For me the xhyve driver, available from https://github.com/zchee/docker-machine-driver-xhyve, worked.
In short:
brew install docker-machine-driver-xhyve
You get a notice some links need to be created manually, so copy those and execute
sudo chown root:wheel /usr/local/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
sudo chown root:wheel /usr/local/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
Create:
docker-machine create --driver xhyve manager
Without VirtualBox. Im using OS X 10.11.6, too.
After updating my docker docker-machine command stopper working on my mac terminal.
So found after updating my docker I'll have to reinstall docker-machine CLI just to get the latest version.
Updated docker-machine to latest one using the command below helped me making docker-machine command working again.
base=https://github.com/docker/machine/releases/download/v0.16.0 &&
curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/usr/local/bin/docker-
machine &&
chmod +x /usr/local/bin/docker-machine
See Docs (https://docs.docker.com/machine/install-machine/#install-machine-directly)

Docker not working in Windows10

I am using Docker version 1.12.2, build bb80604 and VirtualBox 5.1.6.
I was able to install Docker Toolbox correctly but I am not able to start the default VM.
I tried to follow the instruction given here but I am still getting The system cannot find the file specified error. I don't have Hyper-V enabled on system.
F:\>docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default not found Error open C:\Users\Animesh\.docker\machine\machines\default\config.json: The system cannot find the file specified.
F:\>docker-machine env --shell=cmd
open C:\Users\Animesh\.docker\machine\machines\default\config.json: The system cannot find the file specified.
F:\>docker rm default
An error occurred trying to connect: open //./pipe/docker_engine: The system cannot find the file specified.
How can I solve this issue?
It looks like something bad happened to your docker-machine default machine.
To recover, do the following:
docker-machine rm -f default
Next, open the virtualbox GUI and make sure that there isn't a VM that corresponds with that old "default" VM, just in case. If there is, manually delete it from there.
Now, open the quickstart terminal again and it should create a new "default" virtual machine for you.
Alternatively, you can create it like this:
docker-machine create -d virtualbox --virtualbox-memory 2048 default
At that point, your sequence of commands should work as expected again.
You may need another couple of steps additional to what #programmerq mentioned.
Create empty text file: C:\Users\<user>\.docker\machine\machines\default\config.json
Stop VBoxHeadless.exe service from Windows task manager
Try docker-machine rm -f default and docker-machine create -d virtualbox --virtualbox-memory 2048 default commands afterwards to remove/add default
step 1: run: docker-machine rm -f default - (on your mac terminal or control panel)
step 2: run: docker-machine create -d virtualbox --virtualbox-memory 2048 default
It worked like miracle.
If you are a Windows Home user, you will not be able install the Docker for Windows Desktop edition, as it requires Hyper-V virtualization. This is supported only by Windows Professional and Enterprise editions.
As the Docker for Windows Desktop edition requires Hyper-V virtualization, you will not be able to install it if you are a Windows Home user. It is only supported by Windows Professional and Enterprise editions.
If you have installed Docker Toolbox and you are dealing with errors while trying to start the default machine you can create a new one by running:
docker-machine create box
the in order to see how to connect your Docker Client to the Docker Engine running on the virtual machine created run:
docker-machine env box
the command that you need to run in order to configure your shell will then appear:
eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env box)
Check that the installation is runnung correctly by running:
docker run hello-world
Then you just need to start your machine every time you need to use docker:
docker-machine start box
and follow the second and third steps above for the configuration.

Docker Toolbox Mac command line and Kitematics fails

I have installed the new Docker Toolbox application for the Mac using both the graphical installer (the official one) and brew cask install.
In both cases, the Virtual Machine is correctly created, but something seems to be wrong in the environment because when I try to execute docker-machine on the command line, it fails like this:
$ docker-machine env default
open /Users/adeynack/.docker/machine/machines/default/ca.pem: no such file or directory
When I try Kitematics, it fails like this:
I tried Delete VM and retry setup, without success. Any insight or idea is welcome here.
EDIT: I am already using the test build 5.0.3 of VirtualBox.
This may have been caused by an issue with Virtualbox. The issue has been fixed with the latest testbuild for virtualbox here: Virtualbox Test build.
You have to uninstall your current version of Virtual Box and install the test build.
Edit
You may need to create a new docker machine.
Create a new docker machine:
docker-machine create --driver virtualbox dev
Next, start the dev environment:
docker-machine env dev
Set up the environment for the dev machine:
eval "$(docker-machine env dev)"
This worked for me:
docker-machine regenerate-certs default
docker-machine restart default

How to Setup a Docker Tomcat Container on Mac OS X

I'm new to Docker...
From my understanding, Docker is only compatible with Linux, is it possible to run docker for development purposes on a Mac?
I installed virtualbox using homebrew and have tried to create a virtualbox instance. I installed docker, but am having trouble getting my mac to communicate with the vm docker instance. My end goal is to get a locally debuggable instance of tomcat running on the docker container.
Any help or tips would be helpful.
Information:
Because Docker only runs on Linux you will need to install some kind of virtual instance on your local machine. An easy and popular way to do that is to install
Boot2docker and VirtualBox. VirtualBox is a dependency of Boot2docker. You can download, setup and install the latest versions from their websites or if you are using Homebrew, as you mentioned, you can quickly get the working binaries both in one step.
After installing boot2docker, you're ready to use Boot2docker to create a Tomcat Container. You can find a pre-configured tomcat image by searching Docker's community repository, docker hub registry.
Notes:
Each time you execute the docker run command a new container is created.
The VM running Docker requires a ssh private/public encryption key handshake to connect to. If you follow my steps below, one will be generated for you.
Steps to Setup Tomcat using the tomcat image:
Open Terminal and run this command: brew install boot2docker
Create a new Boot2Docker VM instance using the init command: boot2docker init
Run this command in Terminal to forward local ports to the vm:
for i in {10000..10999}; do VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i”; VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";done
Start the boot2docker daemon: boot2docker start or boot2docker up
After starting docker, copy the exports that are displayed from the previous command to your clipboard
Edit your bash profile file ~/.bash_profile (or if you are using zsh, edit the resource configuration file ~/.zshrc) with a text editor (I prefer using Sublime text): subl .zshrc *note: this will permanently save the docker env variables.
Paste the exports into that file and save
Execute the source command on the file: source .zshrc
Pull the latest tomcat image to create a container and start tomcat: docker run -it --rm -p 10080:8080 tomcat:8.0 *note: this will forward your local 10080 port to the vm's 8080 port.
Go to http://localhost:10080, you should see the tomcat start page!
Useful Docker commands:
$ boot2docker status
$ docker version
$ docker ps #shows running containers
$ docker ps -a # shows all containers
$ docker exec -it NAME /bin/bash #to start a bash session on the container. -i = interactive, -t = tty
External Resources:
https://docs.docker.com/installation/mac/#installation
https://registry.hub.docker.com/_/tomcat/
Most people use boot2docker to run on Macs. You may also want to take a look at Kitematic, which gives you a GUI to play with.
Finally, the future is probably to use docker machine, which can provision a VM for you.
Docker requires Linux Kernel features, hence it cannot be run natively on OSX.
See instead Boot2Docker. This link gives you instructions on how to get going.

Resources