Docker socket at host for Docker Machine instance - macos

TL;DR: How do I create or link a Docker socket at /var/run/docker.sock at my host for a Docker Machine instance?
On my Mac, I installed Docker and Docker Machine using Homebrew:
brew install docker docker-machine
I also installed docker-machine-driver-vmware to create a Docker Machine instance based on my hypervisor:
brew install docker-machine-driver-vmware
docker-machine create --driver vmware default
My problem is that I have an application that relies on the Docker socket to create containers, but I cannot find the Docker socket anywhere in my system.
How do I find the Docker socket, and how can I change it or link it to /var/run/docker.sock?

Related

Connecting Docker Windows WSL Ubuntu to VMware Ubuntu

I am trying to connect my Windows 10 Home system to be able to run full Linux OS Docker containers. I have installed Docker on both WSL Ubuntu 18.04 as well as a VMware Ubuntu 18.04.
I was trying to follow this guide.
However, I get stuck trying to configure the Daemon as per the instructions.
Can’t use Docker for Windows?
This is only necessary if you are NOT running Docker for Windows!
No problem, just configure your Docker daemon to use -H tcp://0.0.0.0:2375 and --tlsverify=false. Then you can follow along with the rest of this guide exactly.
If you go down this route, I highly recommend rolling your own VM with VMware Player instead of using the Docker Toolbox because VirtualBox has crazy edge case shared folder bugs that will ruin your life at some point. Don’t worry, VMware Player is free. Just Google how to set up Ubuntu 16 server on VMware Player.
When I try to change the Docker Daemon by making a daemon.json file I get errors. I've also tried editing the .profile files and the .bashrc as per other guides (another guide), with no luck.
I am unable to check the DOCKER_HOST variable on the VM Ubuntu.
Don't make things complicated. In your case, why WSL if you just want to connect to a remote daemon? Why not simply use the windows docker client?
Setup you favorite local VM with docker.
Example: I have installed a CentOS distro running on local VMWare Workstation. All Hyper-V of course deinstalled/deactivated.
In this VM, enable tcp access for the daemon.
If you have a systemd linux distro (like mine CentOS), execute this:
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo echo '[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375' >> /etc/systemd/system/docker.service.d/options.conf
sudo systemctl daemon-reload
sudo systemctl restart docker`
Test if the port is open with docker info. You should get an API access warning at the bottom result.
Download the Windows docker cli zip from here: https://download.docker.com/win/static/stable/x86_64/
Move the docker.exe to any folder, for ex. your Documents folder.
Then put this folder path into your Windows PATH variable.
Set the docker host: Open PowerShell, execute setx DOCKER_HOST <VM-IP>:2375 and close it.
Open a new PowerShell and call docker info.
You should see the docker and daemon infos.
Do what ever you like now... :-)

Volume sharing in Docker and Virtualbox

I have installed docker toolbox on my Windows PC,when i install containers on it using Kitematic, I want to share a folder with my local machine. However docker runs in virtualbox on the default machine in VirtualBox.
So, i guess i first have to do a fvolume share of the virtualbox vm with my local machine and then a second share of the docker container with the folder that I shared in virtualbox. Could someone assist me in this please?
No, you shouldn't need to share any more folder: docker-machine will create a VM which auto-mount C:\Users\<yourLogin>.
docker-machine ls
docker-machine ssh default
cd /C/Users/<yourLogin>
You can mount other folders from your hosts, but you don't have to.
I'm running docker version 18.03.0 ce on Windows 10, and the C:\Users folder is shared as /c-users on the docker VM (default), so using the command line
docker run -it -v /c-users/my_windows_user/project:/media/project ubuntu:16.04 bash
I can access the Windows project files from /media/project within the Ubuntu container

docker-machine cant connect to host/daemon and using insecure registry

So im having some weird problems with docker-machine. I am trying to set up a docker-machine on my Mac OS El Capitan and also have the daemon flagged for a few insecure registries. I was able to successfully push/pull on a local Ubuntu install (without docker-machine) by setting the DOCKER_OPTS options to flag my insecure Nexus docker registries. I am trying to accomplish the same end goal on my Mac OS. So far I have installed the Docker Toolbox using a default installation and have tried the following in Terminal.
Vinays-MacBook-Pro:~ Vinay$ sudo docker-machine create --driver virtualbox --
engine-insecure-registry mynexusrepo.cloudapp.net:18443 --engine-insecure-registry mynexusrepo.cloudapp.net:18444 --engine-insecure-registry mynexusrepo.cloudapp.net:18445 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
Vinays-MacBook-Pro:~ Vinay$ eval "$(sudo docker-machine env dev)"
Vinays-MacBook-Pro:~ Vinay$ sudo docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
dev virtualbox Running tcp://192.168.99.100:2376
Vinays-MacBook-Pro:~ Vinay$ sudo docker pull mynexusrepo.cloudapp.net:18445/docker-thirdparty/mongodb:3.0.2
Password:
Post http:///var/run/docker.sock/v1.20/images/create?fromImage=mynexusrepo.cloudapp.net%3A18445%2Fdocker-thirdparty%2Fmongodb%3A3.0.2: dial unix /var/run/docker.sock: no such file or directory.
* Are you trying to connect to a TLS-enabled daemon without TLS?
* Is your docker daemon up and running?
Vinays-MacBook-Pro:~ Vinay$ sudo docker images
Password:
Get http:///var/run/docker.sock/v1.20/images/json: dial unix /var/run/docker.sock: no such file or directory.
* Are you trying to connect to a TLS-enabled daemon without TLS?
* Is your docker daemon up and running?
Vinays-MacBook-Pro:~ Vinay$ docker-machine -version
docker-machine version 0.4.1 (e2c88d6)
So I know the sudo docker pull mynexusrepo.cloudapp.net:18445/docker-thirdparty/mongodb:3.0.2 command works since it works fine on my straight Ubuntu OS with a docker install. Is there something else I am missing? I have tried closing all the terminals, deleting all of the docker-machines, restarting, etc.
Thanks!

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.

docker0 interface missing on osx

On OSX I followed the installation instructions of boot2docker and am able to build and run Debian containers. However, the documentation states that the host (osx) should have a docker0 interface, binding the container with the host.
However:
$ ifconfig docker0
ifconfig: interface docker0 does not exist
How do I create the docker0 interface on osx?
My goal is to communicate with an open db port on the host machine.
You should use boot2docker ssh to login your virtual machine first.
Boot2docker install virtualbox in your osx and boot a debian distribution on it. And your docker is installed in your virtual machine.
If you want to directly access the containers IP (172.17.0.0/16) which you can retrieve by typing docker inspect <container_id>.
You must have to add the routes from the boot2docker VM by typing sudo route -n add 172.17.0.0/16 $(boot2docker ip)
Then your containers are directly available on your host

Resources