0

I'm trying to build a docker image, but whenever I run the app my connection to localhost gets refused.

The problem does not only occur with port 5000, but also with every else. I'm running the Docker Toolbox on Windows.

My command is :

docker run 5000:80 azure-text

When I curl or just do a docker run, the error message says "Failed to connect to localhost port 5000: Connection refused"

My Dockerfile:

FROM python:2.7-slim

WORKDIR /app_

COPY . /app_

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

EXPOSE 80

ENV NAME World

CMD ["python", "app.py"]

Would be happy about advice!

Infinity Challenger
  • 1,090
  • 10
  • 19

1 Answers1

0

If you're using Docker Toolbox you need an additional port forward to connect to localhost. You can the reach docker in another IP. Run this command to see which host is running your docker host:

docker-machine ls

For example, if your docker machine is running on 192.168.99.100, you can access your running service on http://192.168.99.100:5000

Oresztesz
  • 2,294
  • 1
  • 15
  • 26