0

I've an application running fine inside the docker container :

 * Running on http://127.0.0.1:5000

but this url: http://127.0.0.1:5000 is not accessible from the browser in my local machine. I tried to change the ports in my docker run command, but no luck...

User123
  • 1,498
  • 2
  • 12
  • 26
  • 1
    Is this a Flask application? That output matches [Deploying a minimal flask app in docker - server connection issues](https://stackoverflow.com/questions/30323224/deploying-a-minimal-flask-app-in-docker-server-connection-issues) which has some Flask-specific solutions. More generally, if the process in a container is only listening on 127.0.0.1 it will be unreachable from outside the container. – David Maze Jul 06 '23 at 12:20
  • 1
    (Make sure to include an [mcve] in your questions. This seems likely to be a common problem with an established answer, but given only one line of output with no source code, it's hard to do more than guess at the cause.) – David Maze Jul 06 '23 at 12:29

1 Answers1

1

you can bind the container's port to a port on your local machine using the -p or --publish option when running the container!

for example, if the application inside the container is listening on port 5000, you can use the command

docker run -p 5000:5000 <image_name>

to bind port 5000 of the container to port 5000 on your local machine,and after running the container with this command, you can access the application in your local machine's browser using http://127.0.0.1:5000.

Good luck!

Freeman
  • 9,464
  • 7
  • 35
  • 58
  • the container is already running with '-p 3200:8080' and I'm able to access this container from the browser , here , I've started a new application inside the already running container and the application inside the container is running on : `http://127.0.0.1:5000` ...but unable to access this url from local browser, thanks! – User123 Jul 06 '23 at 12:00