docker: cannot map two container ports to one host port

app.json for pm2 (src/app.py is Flask app):

{
    "apps": [
    {
      "exec_mode": "fork",
      "script": "src/app.py",
      "args": ["-p", "8080"]
    },
    {
      "exec_mode": "fork",
      "script": "src/app.py",
      "args": ["-p", "8081"]
    }
  ]
}
~        

Dockerfile:

  • docker daemon error running devicecreate createpool
  • Unrecognized import path “main/testPackage” when running Go image
  • Docker Rest API '404 NOT FOUND'
  • How to remove a directory in docker?
  • PHPStorm, Docker and debugging
  • How to test code that works with Docker?
  • EXPOSE 8080 8081
    CMD ["pm2", "start", "app.json"]
    

    Error when running docker:

    docker run -p 8080:8080 -p 8080:8081 oct20
    docker: Error response from daemon: driver failed programming external connectivity on endpoint high_fermi (xxxxxxxxxxx): Bind for 0.0.0.0:8080 failed: port is already allocated.
    

    Any ideas? Thanks

  • AWS Network ACL Rules for Docker
  • How to prevent escaping of an ENV variable passed into ruby application in docker container
  • docker global service and replicated service performance
  • Maven's target jar does not exist on Docker Hub
  • Redis: ERR Rewriting config file: Permission denied when using Docker data volume
  • Configuring Docker multi-container App with Spring Cloud Server for OpenShift Origin
  • One Solution collect form web for “docker: cannot map two container ports to one host port”

    You can’t have two things listening on one port in the host – whether they’re separate ports in one container, or two Docker containers, or two other apps. It’s not a Docker limitation, it’s part of the OS networking stack.

    Where would the host send a request to port 8080 if you could do that in this case? To port 8080 in the container, or port 8081, or multicast it to both?

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