Container Networking
Part of the Docker course
You have run a web server in a container, watched it report that it is listening on port 80, and then opened http://localhost:80 in a browser and got nothing at all. The container is fine. The server is fine. Nothing is broken, and the reason is worth understanding properly rather than memorising a flag for.
A container gets its own network. Not a share of yours: its own, with its own IP address, its own set of ports, and its own view of what "localhost" means. Port 80 inside the container and port 80 on your machine are two different port 80s, in the same way that flat 3 in one building and flat 3 in another are two different flat 3s.
Want to learn Docker Container Networking in a real environment?
Click below, get a fresh Linux box with Docker ready to go, and work through Container Networking hands-on with an AI tutor that knows your code.
Start this lessonContainer NetworkingWhat you'll learn
- Published ports
- -p host:container
- User-defined networks
- Container DNS
- Docker network
Read this lesson in your language
All lessons in this course
13 lessons- 1What Is Docker20 min
- 2Your First Container25 min
- 3Images and the Dockerfile30 min
- 4Building Custom Images35 min
- 5Container Networking30 min
- 6Volumes and Persistence30 min
- 7Docker Compose35 min
- 8Multi-Stage Builds35 min
- 9Environment Variables and Secrets25 min
- 10Healthchecks and Restart Policies25 min
- 11Image Optimization and Security30 min
- 12Registries and Publishing25 min
- 13Capstone: Shipping a Stack50 min
