P
P
Pavel2017-12-15 19:51:40
Windows
Pavel, 2017-12-15 19:51:40

How to port forward docker container with flask application to localhost windows network?

There is a windows system, on hyperv the docker creates a Linux system and creates a DockerNAT network. I'm running a container and forwarding port 5000 to the outside.
Where are the settings for creating this virtual machine stored? For at startup, it will automatically install dockernat and not external.
And is it possible to set up a network so that the containers are accessible via localhost?

Thanks in advance!
Docker last 17.09.1

​​And it's not entirely clear where it crashes. I run the command from the docker documentation examples
docker run -d -p 8876:80 --name webserver nginx
AND in the browser by typing localhost:8876 I get access to the nginx greeting By
starting the container from the image:

FROM python:latest

ENV PROJECT = /fileuploader

WORKDIR /fileuploader

ADD . /fileuploader

RUN pip install --trusted-host pypi.python.org -r requirements.txt

EXPOSE 5000

VOLUME ${PROJECT}

ENV FLASK_APP index.py

CMD ["flask","run"]

in pycharm I get a log that the service is running at 127.0.0.1:5000 and in powershell I see that the container is running and forwards the port to 8877
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
3acd9709e8a4        45b9d430ff43        "flask run"              34 seconds ago      Up 32 seconds       0.0.0.0:8877->5000/tcp   pyfileuplo
3b7bdf132ff2        nginx               "nginx -g 'daemon ..."   4 minutes ago       Up 4 minutes        0.0.0.0:8876->80/tcp     webserver

But I can’t get access in the browser. What could be the reason for this?
And as the browser writes - the connection is reset. When I run the curl command from the container itself, I get a working response, i.e. flask itself works in a container.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2017-12-20
@rusbaron

The problem was not in the docker, but in the fact that the flask itself was launched on ip 127.0.0.1 and not 0.0.0.0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question