curl Flask web service inside Docker container

I’ve got a Flask web service running in a Docker container on port 5000. How do I curl this service from inside the container? I can curl it from outside, i.e. the host, using curl http://localhost:5000/<path>.

  • docker registry on localhost with nginx proxy_pass
  • boot2docker command works on shell, but not in script
  • Headless protractor not sharding tests
  • Container Based Application Clustering System
  • How to access Docker container from another machine on lan
  • Docker registry error response from daemon i/o timeout
  • Trouble running docker registry in insecure mode on Ubuntu 16.04
  • Different images in containers
  • apachectl -DFOREGROUND exits immediately
  • Docker & Excelsior JET
  • binding of ports not working in docker
  • Docker - Execute a bash when running a container
  • One Solution collect form web for “curl Flask web service inside Docker container”


    sudo docker inspect --format='{{json .NetworkSettings.Ports}}' <containername or container id>

    In the network section look at ports.

      "443/tcp": [
          "HostIp": "",
          "HostPort": "8443"
      "80/tcp": [
          "HostIp": "",
          "HostPort": "8080"

    As you can see my container is listening on port 80 and 443 so if I use curl inside the container I should use these ports. On the other hand from the docker host I should use HostPorts.

    Alternatively you can look at the Dockerfile to view which ports are exposed.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.