简体   繁体   English

无法访问Docker容器提供的页面

[英]Can't access page served by docker container

I've just started a tutorial on Docker and I've created a container identical to the one here . 我刚刚开始学习Docker教程,并创建了一个与此处相同的容器。 Creating the container works fine, it pulls all the dependencies it needs for python, pushing to docker hub works fine as well. 创建容器可以正常工作,它可以拉取python所需的所有依赖项,并推送到docker hub也可以。

I then run the container using the following command: 然后,我使用以下命令运行容器:

docker run -p 4000:80 username/get-started:part2
 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)

When I access localhost:4000, it says it refuses to connect. 当我访问localhost:4000时,它说它拒绝连接。 On a different thread, I saw the command docker-machine being mentioned. 在另一个线程上,我看到了提到的命令docker-machine Gave that a try, this is the result. 经过尝试,这就是结果。

docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL   SWARM   DOCKER   ERRORS
default            virtualbox   Timeout

docker-machine ip default
Error getting IP address: Host is not running

docker ps
CONTAINER ID        IMAGE                         COMMAND             CREATED             STATUS              PORTS                          NAMES
881e9a9ebf21        username/get-started:part2   "python app.py"     21 minutes ago      Up 21 minutes       80/tcp, 0.0.0.0:80->4000/tcp   happy_raman

I am running Docker on Windows 10 64 bits and I'm using the Docker Toolbox Terminal . 我正在Windows 10 64位上运行Docker,并且正在使用Docker Toolbox Terminal

What could the problem be? 可能是什么问题?

First you can get the docker machine IP: 首先,您可以获得docker机器IP:
1. Using command docker-machine : docker-machine ip 1.使用命令docker-machinedocker-machine ip
2.or By login to the docker image and getting the eth1 ip 2.或通过登录到docker映像并获取eth1 ip

Then try : [docker-machine ip]:4000 然后尝试:[docker-machine ip]:4000

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

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