What is Port Binding?
Port Binding = Connecting container's internal port to your computer's port so you can access the app.
Think of it:
- Container = House with door number (port 5000)
- Your PC = Street with address (port 8080)
- Port binding = Creating a pathway between them
Without Port Binding ❌
docker run my-app
Problem:
- App runs on port 5000 inside container
- You cannot access it from browser
- It's isolated!
With Port Binding
bash
docker run -p 8080:5000 my-app
# ↑ ↑
# Your PC : Container
Now:
- App runs on port 5000 inside container
- Accessible at
http://localhost:8080 on your PC