[英]Docker access localhost in browser
I use Docker Compose for Windows and I can't access to localhost:3333 from browser (Windows).我为 Windows 使用 Docker Compose,但我无法从浏览器(Windows)访问 localhost:3333。
This is my docker-compose.yml这是我的 docker-compose.yml
version: '2'
services:
data:
image: mongo:latest
volumes:
- "./data:/usr/app/data"
ports:
- "27017:27017"
command: mongod --logpath=/dev/null # --quiet
web:
image: rifton007/nodejs
command: adonis servev --dev
links:
- data
volumes:
- .:/usr/app/
- /usr/app/node_modules
ports:
- "3333:3333"
In browser with localhost:27017, I can access to Mongo Container.在带有 localhost:27017 的浏览器中,我可以访问 Mongo Container。 But localhost:3333 return me "ERR_CONNECTION_REFUSED".
但是 localhost:3333 给我返回“ERR_CONNECTION_REFUSED”。
However, adonis servev --dev
it's correctly running and when I tried ``curl localhost:3333 in the container, i can see html code of the web page.但是,
adonis servev --dev
它运行正常,当我在容器中尝试 ``curl localhost:3333 时,我可以看到 web 页面的 html 代码。
Thanks you,谢谢,
You should be using the docker machine ip.您应该使用 docker 机器 ip。 I have to do the same on my windows 10 box.
我必须在我的 windows 10 盒子上做同样的事情。 Run
docker-machine ip
and use that plus your port
number and see if it works运行
docker-machine ip
并使用它加上你的port
号,看看它是否有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.