简体   繁体   English

无法从浏览器查看在Docker容器中运行的Rails应用

[英]Unable to view rails app running in docker container from browser

I am running a rails app in a docker container and after executing docker-compose up I look in the browser and see ERR_CONNECTION_REFUSED . 我在Docker容器中运行Rails应用程序,执行docker-compose up我在浏览器中查看ERR_CONNECTION_REFUSED I have tried port forwarding via docker run -p 3000:3000 docker_app and still nothing. 我已经尝试通过docker run -p 3000:3000 docker_app端口转发,但还是一无所获。 Any ideas? 有任何想法吗?

If you are using boot2docker or docker toolbox or docker machine (on an OS different from Linux, meaning using a VirtualBox VM), that means you need to forward that port at the VM level itself: 如果您正在使用boot2docker或docker工具箱或docker机器(在与Linux不同的操作系统上,这意味着使用VirtualBox VM),这意味着您需要在VM级别本身转发该端口:

VBoxManage controlvm boot2docker-vm natpf1 "name,tcp,,3000,,3000"

The VM needs to forward that port from localhost to itself, before the docker port mapping can act. VM必须先将端口从本地主机转发到自身,然后才能执行docker端口映射。
I had a similar case with this answer . 我也有类似的情况与此答案

Then try to access http://$(docker-machine ip default):3000 , as mainframer comments. 然后尝试访问http://$(docker-machine ip default):3000作为大型机注释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM