boot2docker on windows - Can't access exposed port - windows

I've installed boot2docker (full install) on Windows 7 and am trying to run the container port redirection demo:
docker run --rm -i -t -p 80:80 nginx
Which looks like it isn't quite finishing properly, it just stops and looks like this:
When I open another git bash shell and run boot2docker ip I get 192.168.59.103, and when I pop that in chrome I get Error code: ERR_CONNECTION_TIMED_OUT
It works fine for me with plain docker on Ubuntu 14.04. What else do I need to do to make it work with boot2docker on windows?

Looking more closely, my problem is the same as this question: Docker, can't reach “rails server” development from localhost:3000 using docker flag -p 3000:3000
The answer to that question that worked for me was this one, which simply says to run
boot2docker ssh -L 8080:localhost:80
at the terminal before starting boot2docker
In my case I do this (from a git bash terminal):
boot2docker init # from https://github.com/boot2docker/boot2docker
boot2docker up
boot2docker ssh -L 8787:localhost:8787 # sets up port forwarding and starts boot2docker
docker run -d -p 8787:8787 cboettig/rstudio # starts the container I want
then go to my web browser in windows and point it to http://localhost:8787/ and I get a server instance of RStudio. When I'm done:
docker rm -f $(docker ps -a -q) # delete all containers
UPDATE: downgrading to an earlier version of VirtualBox will fix this
After struggling with folder sharing I regressed through previous versions of VirtualBox and found that with version 4.3.12 I could enable folder sharing and have the port forwarded exactly according to the official instructions, that is I could access my docker container at 192.168.59.103. So downgrading VirtualBox is another option for working around this problem.
ANOTHER UPDATE: updating to the new release of v1.3.1 of boot2docker will fix this
This release just came out a week ago and includes VirtualBox Guest Additions, which simplifies all of this. I now simply do
boot2docker ssh # start boot2docker
docker run -d -p 8787:8787 -v /c/Users/foobar:/home/rstudio/foobar rocker/rstudio
And I get everthing working as expected and can log into RStudio in my browser at http://localhost:8787/ (linux) or http://192.168.59.103:8787 (Windows) and it just works.
In this case I've also got folder sharing working with, /c/Users/foobar corresponding to an existing folder on my computer at C:/Users/foobar, and foobar can be anything. With this method I can read and write files both ways between Windows and RStudio and I don't need to connect to a special IP address like the samba method does in the official docs

I had this problem too after a couple of failed attempts to boot2docker start. This created multiple entries of host-only networks configured on VirtualBox (VirtualBox Host-Only Ethernet Adapter #2, VirtualBox Host-Only Ethernet Adapter #3), and probably the boot2docker's VM was using a bad one.
I cleaned up using Virtualbox standard UI, leaving only one of the networks and now everything works fine.
I'm using boot2docker 1.5.0.
Just to register something that happened to me, and made me lose a couple of hours.

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... :-)

Setting up docker on the mac: Cannot connect via localhost

I'm just setting up docker on my Mac. The installation worked and I got some containers running (following the getting-stared guide), but now I want to connect with my browser to localhost, to show a web app.
For that I'm following this guide: https://docs.docker.com/engine/userguide/containers/usingdocker/
In the last section it is said, that you simple go with your browser to: localhost:XXXXX wheras XXXXX is the port, that you found out using the command
docker ps -l
First problem: here nothing happends. The browser is showing an empty page (ERR_CONNECTION_REFUSED)
Further more in the guide it is explained, that for Mac you can check your ip address via the command:
docker-machine ip your_vm_name
Here appears the second problem: This command results in an error-message:
Host does not exist: "your_vm_name"
So my questions are:
How to set up the virtual machine (or "your_vm_name" respectively)?
Does it have to do anything with the vhosts file on my Mac OS?
Is there mybe a conflict with MAMP (which I'm also using sometimes)?
Thanks in advance!
And thanks to GianArb for the very fast answer! That solution works as well.
Just to contribute to the community, I just found out by myself, that the solution was too simple to be true.
Instead of your-vm-name use default (obviously the default-host that is set up by docker), so I just used:
docker-machine ip default
and then I got the right IP.
Hello the process to start to use docker on mac with docker-machine is like:
Create a new docker machine on virtualbox, you can use a name like "your_vm_name" or just "default" in this way you can not use the name because "default" is a keyword that docker-machine try to use when you don't specify nothing.
The problem here is, why docker-machine ip your_vm_name doesn't provide the good ip? Can you copy the result of your command
echo $DOCKER_HOST
Usually it's 192.168.99.100
thanks a lot
Actual for Mac OS:
If there is no real need in VirtualBox machine you can just remove it.
Docker can start Linux containers under Mac OS without any VirtualBox machines.
Without any VirtualBox machines, all exported ports are available on the localhost:*.
Remove docker machine
docker-machine ls
docker-machine stop default
docker-machine rm default
Make sure that you don't have the command eval $(docker-machine env ...) in your ~/.bashrc or ~/.zshrc.
Otherwise, nothing will work. You will see the error Error: No machine name(s) specified and no "default" machine exists.
By the default configuration no need to have any env variables like $DOCKER_*
In my case, the only docker installed by downloading a .dmg image from the official site works without any problems. Any versions installed via brew didn't work out of the box.
PS: tested on Mac OS 10.13 and 10.14

Running Boot2Docker on windows, can't connect to the VM ip

I can't make Docker run the Hello-world or any of server-connection things, as you can see it gives me the client version but at the time of giving me the server version it just can't connect...
I have boot2docker 1.7.0 and running on Windows 7.
This looks like your Boot2Docker VM is not running. The docker command tries to connect to the Boot2Docker VM through this IP and port, and it looks like it can't access this IP/port combination. I get a similar error (although not in Spanish) when I try to run docker version without starting Boot2Docker first.
Can you go through the steps listed in the Docker documentation again:
Run the Boot2Docker Start shortcut from your Desktop or “Program Files → Boot2Docker for Windows”. The Start script will ask you to enter an ssh key passphrase - the simplest (but least secure) is to just hit [Enter].
When doing this, do you see the environment variables printed like in the following screenshot?
Do you see these variables, or do you see any error messages instead?

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.

boot2docker changing IP address from default 192.168.59.103 to 192.168.59.104 (Mac)

boot2docker was running all the time on 192.168.59.103.
Suddenly the command boot2docker ip gives 192.168.59.104.
The problem is that now I have to change all my /etc/hosts entries.
How can I make the boot2docker IP address static?
Side question: Should I avoid boot2docker completely and run everything inside a Vagrant machine?
I am running on Mac OS X v10.10 (Yosemite).
If you haven't already done so, create a Docker configuration with:
boot2docker config > ~/.boot2docker/profile
Then edit your Docker configuration with the following line:
UpperIP = "192.168.59.103"
Then follow the other steps to clear out your old Docker images and start a new one.
I was also having issues connecting to Docker, but a system restart resolved them.
In order to remove the VM and restart it again like #ramden suggested you could do:
You can remove all containers from the current environment by running
$ docker rm $(docker ps -a -q)
To remove all images:
$ docker rmi $(docker images -q)
Restart the VM, cleaning all cache from old images, doing the following
$ boot2docker delete
$ boot2docker init
$ boot2docker start
I've just encountered the same issue and couldn't find an answer right away, maybe this is worth for future interest.
Cheers.
After removing the virtual machine from the VirtualBox GUI (delete everything) it works again on 103. I guess something messed up with boot2docker while using it.

Resources