Vagrant mount error after installing Docker - docker

I'm getting a strange error in my vagrant VM. So I created a new ubuntu/trusty64 VM using VirtualBox (on OS X if anyone cares).
All fine there...
Then I installed Docker as per the instructions which basically involves running
wget -qO- https://get.docker.com/ | sh
That works fine too.
Then I go to reboot the VM, I exit the ssh shell, and run vagrant reload and I get this error message.
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant
The error output from the last command was:
stdin: is not a tty
/sbin/mount.vboxsf: mounting failed with the error: No such device
Any thoughts?

I faced similar issues. Looks like Docker (and potentially other tools) when installed will update the kernel version in your Ubuntu/Trusty64 guest. Since the VBox GuestAdditions that came preinstalled in Ubuntu/Trusty64 were specifically built against the original kernel version, the Guest Additions will stop working in the next vagrant up or vagrant reload as that's when the new kernel installed by Docker kicks in. At that point, Vagrant is no longer able to auto-mount /vagrant folder (or any synced folder for the matter) as the Guest Additions were built against a different kernel.
To get them working again you'd have to rebuild the GuestAdditions against the new kernel version that Docker installed.
Luckily, there's a plugin in Vagrant called vagrant-vbguest that takes care of automatically rebuilding the Guest Additions when the plugin detects they need to be rebuilt (i.e. like when the kernel in the guest changes, or you upgraded your VirtualBox version in the host)
So in my case, the easy way to fix it was to:
On the host: $ vagrant plugin install vagrant-vbguest
On the guest: $ sudo apt-get install linux-headers-$(uname -r)
On the host: $ vagrant reload
Thanks to the vagrant-vbguest plugin, new VBox GuestAdditions will be automatically rebuilt against the new version of your kernel (for which you would have downloaded the required headers in the second step above).
Once the GuestAdditions are back in shape, synchronized folders should be working again and the mapping of /vagrant should be successful.
Give it a try.

Related

How do I access the Docker CE virtual machine on MacOS BigSur?

I'm running the Docker community edition on MacOS BigSur (11.2.2), and am trying to get into the virtual environment.
This article from 2018 says to do
$screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
and this one from February 2020 says
$ screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
But neither of those things seem to work in my current install.
$docker --version Docker version 20.10.5, build 55c4c88
The methods you have found are backdoors for entering in the virtual machine, and they change when the releases are changing, and both mentioned methods are no longer supported on the latest Docker-for-mac.
The most canonical way to get terminal access to the virtual machine (create a sh process in the virtual machine and get tty from it), you need the following command.
docker run -it --privileged --pid=host debian nsenter -t 1 -m -u -n -i sh
This approach will create a container and will join it to the namespace of the host, after which it will create a new shell in the namespace of the init (pid 1) by executing the nsenter command. This will not change much with the later releases since it relies on stabile docker features to get the access to the vm. In the example I had used debian, but you can replace this with any image that has nsenter (ex. alpine, busybox, etc.)
Also, you can get access trough the current debug socket which will create a shell directly in the virtual machine and connect to it. This is more a backdor created for debugging and might be removed/changed in future releases.
stty -echo -icanon && nc -U ~/Library/Containers/com.docker.docker/Data/debug-shell.sock && stty sane

Error in Docker: bad address to executables

I'm trying to something with Docker.
Steps I'm doing:
- Launch Docker Quickstart Terminal
- run docker run hello-world
Then I get error like:
bash: /c/Program Files/Docker Toolbox/docker: Bad address
I have to say that I was able to run hello-world image, but now I'm not. I don't know what happend.
I don't know if it matters however I had some problems at instalation step.
Since I have git installed in non standard location. However it seems git bash.exe working correctly for Docker.
My environment:
Windows 10
Git 2.5.0 (installed before Docker)
Docker Toolbox 1.9.1a
I have the same issue with bash: /c/Program Files/Docker Toolbox/docker: Bad address
I thought the problems is "bash doesn't support docker.exe".
SO I fix this problem by use powershell ,not the bash.
and if you use powershell maybe face this
An error occurred trying to connect: Get http://localhost:2375/v1.21/containers/json: dial tcp 127.0.0.1:2375: ConnectExenter code here
tcp: No connection could be made because the target machine actively refused it.
You can export variable from bash use export and import to powershell by this below
$env:DOCKER_HOST="tcp://192.168.99.100:2376"
$env:DOCKER_MACHINE_NAME="default"
$env:DOCKER_TLS_VERIFY="1"
$env:DOCKER_TOOLBOX_INSTALL_PATH="C:\\Program Files\\Docker Toolbox"
$env:DOCKER_CERT_PATH="C:\\Users\\kk580\\.docker\\machine\\machines\\default"
that's all
ps:I found this problem fixed by update git from 2.5.0 to 2.6.3.
Not entirely sure what the issue is, report it to the project on github. I find the docker mac and windows tools a bit flakey from time to time as they are still maturing. If you don't mind seeing what's underneath, you can try running docker-machine directly or set up your own host pretty quickly with Vagrant.
Docker Machine
Run a command or bash prompt to see what machines you have.
docker-machine ls
Create a machine if you don't have one listed
docker-machine create -d "virtualbox" default-docker
Then connect to the listed machine (or default-docker)
docker-machine ssh default-docker
Vagrant
If that doesn't work you can always use vagrant to manage VM's
Install VirtualBox (Which you probably have already if you installed the toolbox)
Reinstall Git, make sure you select the option for adding ALL the tools to your system PATH (for vagrant ssh)
Install Vagrant
Run a command or bash prompt
mkdir docker
cd docker
vagrant init debian/jessie64
vagrant up --provider virtualbox
Then to connect to your docker host you can run (from the same docker directory you created above)
vagrant ssh
Now your on the docker host, Install the latest docker the first time
curl https://get.docker.com/ | sudo sh
Docker
Now you have either a vagrant or docker-machine host up, you can docker away after that.
sudo docker run -ti busybox bash
You could also use PuTTY to connect to vagrant machines instead of installing git/ssh and running vagrant ssh. It provides a nicer shell experience but it requires some manual setup of the ssh connections.

NFS Server on OSX - squash options

Is it possible to have no_root_squash option enabled on an OSX Yosemite NFS server?
I'm running boot2docker on OS X in Yosemite via Virtualbox (boot2docker 1.8 - from Docker Toolbox).
Due to performance issues with large mounted host-volumes, I thought about giving NFS a shot!
This is my /etc/exports
/Users/myuser -mapall=myuser:staff 192.168.99.100
This is my /etc/nfs.conf
nfs.server.mount.require_resv_port = 0
And that script is executed in boot2docker-vm
#!/bin/sh
sudo umount /Users
sudo mkdir -p /Users/myuser
sudo /usr/local/etc/init.d/nfs-client start
sudo mount 192.168.99.1:/Users/myuser /Users/myuser -o rw,async,noatime,rsize=32768,wsize=32768,proto=tcp,nfsvers=3
And inside a container I use a bash script that reads the UID and GID of a mounted volume and changes the UID and GID of a non-privileged user in order to allow read/write operations.
So far so good. But sometimes I would need to change file permissions, however sudo chmod/chown don't work because all operations are matched against my local (unprivileged) user on OSX. NFS on Linux is supporting the option no_root_squash which would perfectly solve my problems, but I'm afraid it's it's not available on OSX Yosemite.
And it's not possible to use -mapall along with -maproot.
And no, I don't want to map against root on OS X too :)
Any ideas?

Why is my docker machine not working under OSX?

I've installed Docker Toolbox v1.8.1b on OSX 10.10.5
This also installs VirtualBox v5.0.2
However, when the installation has finished and I run the Docker Quickstart Terminal, it does its thing, creates a new VM in virtualbox but then doesn't start it, finishing with the message that default is not running.
When I try to run the machine using docker-machine start default I get the message exit status 1.
When I go to VirtualBox and attempt to start the machine there, I get the following error message:
Failed to load VMMR0.r0 (VERR_VMM_SMAP_BUT_AC_CLEAR).
Result Code:
NS_ERROR_FAILURE (0x80004005)
Component:
ConsoleWrap
Interface:
IConsole {872da645-4a9b-1727-bee2-5585105b9eed}
So is anyone else getting this or am I not following the instructions properly?
I had exactly the same problem. It seems that there is a bug in recent versions of VirtualBox, which is fixed in the latest test build. See https://www.virtualbox.org/ticket/14412
I downloaded the latest VirtualBox test build from
https://www.virtualbox.org/wiki/Testbuilds
then used the uninstaller script provided in that installer to remove the buggy version before installing the new one.
Running the Docker QuickStart Terminal again got the default VM running, but it was missing a ca.pem file:
docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com
open /Users/justin/.docker/machine/machines/default/ca.pem: no such file or directory
VirtualBox confirmed that the VM was running.
I could create a new VM and use it with docker successfully (in a different Terminal window):
Justins-MacBook:~ justin$ docker-machine create --driver virtualbox dev
Creating VirtualBox VM...
Creating SSH key...
Starting VirtualBox VM...
Starting VM...
To see how to connect Docker to this machine, run: docker-machine env dev
Justins-MacBook:~ justin$ eval "$(docker-machine env dev)"
Justins-MacBook:~ justin$ docker run hello-world
...
I then deleted the default VM:
Justins-MacBook:.docker justin$ docker-machine stop default
Justins-MacBook:.docker justin$ docker-machine rm default
Successfully removed default
Running the Docker QuickStart Terminal created a new default VM, and docker is now working happily with it.
Update: There is an open issue for this at: https://github.com/docker/toolbox/issues/119
Just wanted to add: if you have docker for mac installed, they intentionally removed the docker-machine command starting from version 2.2.0.
You can find the discussion here: https://github.com/docker/for-mac/issues/4208
So, you need to install docker-machine separately, using the commands provided by #shivanikoko or using brew:
brew install docker-machine
ON Osx after installing docker or updating docker we have to reinstall the docker-machine again to make it work in CLI.
Running the command below helped me.
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

docker-machine install fails due to 'Couldn't read CA cert' error

I am trying to setup docker-machine locally on my Windows machine and I followed the install instructions at the Docker Machine Page.
Per the instructions, I ran the following commands in my bash terminal
To install Docker client binary
$curl -L https://github.com/docker/machine/releases/download/v0.3.0/docker-machine_windows-amd64.exe > /bin/docker-machine
and to install Docker machine binary
$ curl -L https://github.com/docker/machine/releases/download/v0.3.0/docker-machine_windows-amd64.exe > /bin/docker-machine
when I try to run docker-machine -v I get the following error
FATAL[0000] Couldn't read ca cert 'C:\Users\Me\.boot2docker\certs\boot2doker-vm\ca.pm: open 'C:\Users\Me\.boot2docker\certs\boot2docker-vm'\ca.pem: The filename, directory name, or volume label syntax is incorrect.
I did some searching and came across a few posts, but can't really see any connection to what would be causing my issues...
https://github.com/hypriot/kitematic/pull/1
https://github.com/docker/machine/issues/908
I installed docker machine today on my Windows 7 machine and run the command without any problem.
Did you use boot2docker before on your machine? If you did, it might be related as mine is a clean machine without any pre-existing docker installations.
Its referring to boot2docker environment.
see this:
DOCKER_CERT_PATH="/Users//.docker/machine/machines/dev"
I got the same answer and was able to resolve it by changing the path pattern to be unix-style in the environment variable.
Inside msysgit bash shell:
export DOCKER_CERT_PATH=/C/Users/Me/.boot2docker/certs/boot2docker-vm
This resolved boot2docker.
Note that I also tried using docker-machine before using boot2docker which previously failed with the same error. That was not resolved the same way boot2docker could be resolved. For now only boot2docker is working for me.

Resources