docker-machine:Error with pre-create check: "exit status 126" - macos

When I'm type the code sudo docker-machine create --driver virtualbox default to create a new virtual machine. It can not worked. Here is the info:
xxxMacBook-Pro:~ xxx$ docker --version
Docker version 1.12.0, build 8eab29e
xxxMacBook-Pro:~ xxx$ docker-machine --version
docker-machine version 0.8.0, build b85aac1
xxxMacBook-Pro:~ xxx$ sudo docker-machine create --driver virtualbox default
Running pre-create checks...
Error with pre-create check: "exit status 126"
Please help me to figure this out.

Exit status 126 on a Mac indicates that you don't have Virtualbox installed, which comes separate from Docker.
Run the following command to install it:
brew cask install virtualbox;
Now you can gracefully run your command again.
NB: You don't have to use sudo, unless there are some special privileges you want to accord whatever you are creating.
Update: As of 2021 you can use
brew install --cask virtualbox

The same error occurred on my OSX, because I'v only installed docker.app.
Probably, you should install docker toolbox instead of docker.app.
Docker.app doesn't include virtualbox driver, but docker toolbox includes virtual box driver.
https://www.docker.com/products/docker-toolbox

I had the same problem with Docker for Mac. You need to install VirtualBox additionally from https://www.virtualbox.org/wiki/Downloads

Related

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)

How to forward Docker for Mac to X11?

Using Docker for Mac 1.12 (stable) and OS X 10.11.5 (15F34), I'm attempting to make one of my containers forward to X11.
First, I install XQuartz from my bash shell:
$ brew cask install xquartz
==> Downloading https://dl.bintray.com/xquartz/downloads/XQuartz-2.7.9.dmg
######################################################################## 100.0%
==> Verifying checksum for Cask xquartz
==> Running installer for xquartz; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
Password:
==> installer: Package name is XQuartz 2.7.9
==> installer: Installing at base path /
==> installer: The install was successful.
🍺 xquartz staged at '/usr/local/Caskroom/xquartz/2.7.9' (73M)
Then I continue with setting up XQuartz...
open -a XQuartz
In the XQuartz Preferences -> Security tab, I enable "Allow connections from network clients".
Then I am supposed to run xhost + $MY_IP_ADDRESS in my bash shell, but all I get is this error:
xhost: unable to open display ""
In the end, all guides I'm reading says I should run my container like this:
docker run -e DISPLAY=$MY_IP_ADDRESS:0 -v /tmp/.X11-unix:/tmp/.X11-unix DOCKER_IMAGE
...but that doesn't work. In my particular container, I get this error:
... cannot connect to X server 10.0.0.131:0
What am I doing wrong?
Turns out there's a bug in XQuartz 2.7.9.
When using XQuartz 2.7.10_beta2, it works.
I have xQuartz 2.7.11 installed on Mac OS.
I was getting the following error
<program>: cannot connect to X server <ip>:0
when trying to run docker container. I tried downgrading XQuartz but it still didn't fix my issue.
A crucial piece to to the setup is to add your ip access control list for xhost.
xhost + $(ipconfig getifaddr en0)
After adding the ip to xhost, everything works. There is no need to downgrade Xquartz version.
Solution
After installing XQuartz you will need to restart your computer as horcle_buzz suggested; starting a new terminal session is not enough.
After a reboot you can grant access for whatever you need using the xhost command. Just be careful and understand the consequences of too permissive a rule. This other discussion has more info: Running Chromium inside Docker - Gtk: cannot open display: :0
Additional findings
Some extra things I discovered along the way:
XQuartz must be running first:
$ open -a XQuartz
You can expose 127.0.0.1 instead of looking up your local IP (caveat emptor: I'm not an expert on the implications of this setting):
$ xhost + 127.0.0.1
127.0.0.1 being added to access control list
You can use the special host.docker.internal identifier with docker run:
$ docker run -e DISPLAY=host.docker.internal:0 jess/firefox
# 🧙‍♀️ magic 🧙‍♂️
At least for me, ctrl + c does not shutdown the container; I need to close the X11 window manually.
If you quit XQuartz, you must re-auth with xhost after starting it again (the permission doesn't "stick").
Doing it this way I didn't need to mount /tmp/.X11-unix when calling docker run.
I tested this with XQuartz 2.7.11 and Docker Desktop 2.1.0.2 on macOS Mojave (10.14.6).

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

Error when Vagrant Up running?

I am using vagrant on Ubuntu 14.04 and the version of it is Vagrant 1.4.3. When I am tiring to up the vagrant, Its giving me following error every time.
Successfully added box 'precise64' with provider 'virtualbox'!
There are errors in the configuration of this machine. Please fix
the following errors and try again:
shell provisioner:
* The following settings shouldn't exist: run
My virtualbox version = 4.3.10_Ubuntur93012
Please help me on this its blocking my every workflow :(
Install the latest version of Vagrant on your Ubuntu machine (assuming 64-bit):
Remove your old version of Vagrant: sudo apt-get remove vagrant
Copy the Debian 64-bit download link from https://www.vagrantup.com/downloads.html
In your console, type wget, paste in the download link from step 2, and hit enter (should look like wget https://releases.hashicorp.com/vagrant/x.x.x/vagrant_x.x.x_x86_64.deb)
Enter sudo dpkg -i vagrant_x.x.x_x86_64.deb, where x.x.x is the current Vagrant version
Credits:
https://www.howtoforge.com/tutorial/ubuntu-vagrant-install-and-getting-started/
http://www.icchasethi.com/installing-latest-vagrant-and-virtualbox-version-on-ubuntu-12-01/

Installing docker with devstack

I am trying to install devstack and docker (http://devstack.org/guides/single-machine.html) onto a VM containing Ubuntu 13.10 Server. devstack contains a docker installer script in tools/docker/install_docker.sh which it is recommended to run first before running the stack.sh installer script for devstack. I have patched the docker install script according to the bug report https://bugs.launchpad.net/devstack/+bug/1237581 however docker still reports a problem:
socat[NNNN] E connect(3, AF=1 "/var/run/docker.sock", 22): Connection refused
Does anyone know a fix for this problem?
Thanks,
David
If you get error messages regarding /var/run/docker.sock then either the docker daemon/service is not started or your user (devstack user) has no permissions.
Start docker:
service docker restart
Add your user (devstack user) to the docker group. Try to enumerate containers:
docker ps
If that still does not fix the problem then you might want to change the permission of /var/run/docker.sock directly:
sudo chown vagrant:vagrant /var/run/docker.sock
Check your kernel ( uname -a ) and make sure it is 3.8 or latest. Also, make sure you are on a 64bit Ubuntu ( X86_64 distribution ). The point is that the Docker daemon might not be starting (fails) because it is not supported on a 32 bit distribution.

Resources