connor449
connor449

Reputation: 1679

Docker flask app working on Mac but not Windows OS

I built a docker app that works across multiple Mac machines. However, when it is run on Windows 10 (with the most up to date Docker installed), the following error is produced when going to http://0.0.0.0:5000/

This site can’t be reached
The webpage at http://0.0.0.0:5000/ might be temporarily down or it may have moved permanently to a new web address.
ERR_ADDRESS_INVALID

For reference, the file flaskapp.py ends with:

if __name__ == '__main__':
    app.run(host= '0.0.0.0')

The Dockerfile looks like this:


FROM python:3
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . /app
EXPOSE 5000
CMD [ "python", "flaskapp.py" ]

The docker was built and pushed to docker hub, then pulled and run with the command:

docker run -p 5000:5000 username/reponame

When run on multiple Mac machines, the terminal prints out:

 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

and I can navigate to the browser with this address and my app works.

On windows, it prints the same thing in the command line, but the site cannot be reached.

Any ideas? I thought docker was supposed to work across platform.

Upvotes: 0

Views: 433

Answers (1)

alv2017
alv2017

Reputation: 850

It is not the way to do it. You have to use host's or container's IP addresses. For starters try to type in your browser:

  1. http://localhost:5000

  2. http://127.0.0.1:5000

You can also try to run in Windows command line: ipconfig

This should give you a list of IP addresses that your Windows host has, then you can try access your app using those addresses.

Upvotes: 1

Related Questions