What You'll Learn
Beginner
- The difference between EXPOSE and -p
- How to publish ports correctly
The #1 confusion
EXPOSE is documentation only. -p actually publishes the port.| EXPOSE (Dockerfile) | -p (docker run) |
|---|---|
| Documentation only | Actually publishes |
EXPOSE 3000 | -p 3000:3000 |
Key Takeaways
EXPOSEis documentation — does NOT publish ports.-p host:containeractually maps ports.- Don't publish database ports unless needed.
- On custom networks, containers communicate directly.
Comments
Comments
Post a Comment