What does -p 8080:8000 mean in docker run -p 8080:8000 myapp?
Options
- Use 8080 MB of memory for the container while it is running
- Forward port 8080 of your computer to port 8000 of the container (Correct option)
- Run 8080 copies of the container at the same time on one host
- Limit the app inside the container to 8000 requests per second
Answer
Forward port 8080 on your computer to port 8000 inside the container
Why
The app inside the container listens on its own port 8000, which is isolated from your computer.
-p HOST:CONTAINER publishes it: requests to http://localhost:8080 on your machine are forwarded to port 8000 in the container.
Inside the container, the app must listen on 0.0.0.0 (all interfaces), not only 127.0.0.1.
Remember
-p host_port:container_port.