Windows上的boot2docker - 无法访问暴露的端口 [英] boot2docker on windows - Can't access exposed port
问题描述
我已经在Windows 7上安装了boot2docker(完全安装),并尝试运行,它简单地说要运行
boot2docker ssh -L8080:localhost:80
$ c $在启动boot2docker之前,终端上的c>
在我的情况下,我做这个git bash终端):
boot2docker init#from https://github.com/boot2docker/boot2docker
boot2docker up
boot2docker ssh -L 8787:localhost:8787#设置端口转发并启动boot2docker
docker run -d -p 8787:8787 cboettig / rstudio#启动容器我想要
然后在Windows中转到我的网络浏览器,并将其指向 http :// localhost:8787 /
我得到一个RStudio的服务器实例。完成后:
docker rm -f $(docker ps -a -q)#删除所有容器
更新:降级到较早版本的VirtualBox将修复此
在与文件夹共享挣扎之后我通过以前版本的VirtualBox退化,发现使用版本4.3.12,我可以启用文件夹共享并且根据官方说明准确地转发端口,即可以访问我的docker容器 192.168.59.103
。所以降级VirtualBox是解决这个问题的另一个选择。
另一个更新:更新到boot2docker v1.3.1的新版本将修复这个
此发布刚刚在一个星期前出来,包括VirtualBox Guest Additions,这简化了所有这一切。我现在只需要执行
boot2docker ssh#start boot2docker
docker run -d -p 8787:8787 -v / c / users / foobar:/ home / rstudio / foobar rocker / rstudio
并可以在我的浏览器中登录到RSTudio,位于 http:// localhost:8787 /
(linux)或 http://192.168.59.103:8787
(Windows),它只是工作。
在这种情况下,我也有文件夹共享, / c / Users / foobar
对应于我的电脑上的现有文件夹, C:/ Users / foobar
和 foobar
可以是任何东西。使用这种方法,我可以在Windows和RStudio之间读取和写入文件,我不需要连接到一个特殊的IP地址,如samba方法在官方文档中
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
这篇关于Windows上的boot2docker - 无法访问暴露的端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!