简体   繁体   中英

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 . Creating the container works fine, it pulls all the dependencies it needs for python, pushing to docker hub works fine as well.

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. On a different thread, I saw the command docker-machine being mentioned. 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 .

What could the problem be?

First you can get the docker machine IP:
1. Using command docker-machine : docker-machine ip
2.or By login to the docker image and getting the eth1 ip

Then try : [docker-machine ip]:4000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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