Docker Docker NetworkingPort Mapping

Article & Tutorial

Docker Networks Explained: Bridge, Host, None, Custom Networks and Port Mapping

Understand bridge, host, none, and custom Docker networks, service discovery, DNS, port publishing, container communication, troubleshooting, and security.

Docker networking and container port mapping
Docker networking and container port mapping
Contents

Docker Networks Explained

Docker networks allow containers to communicate with each other, the host, and external systems. This guide explains bridge networks, host network, custom networks, DNS, and port publishing.

Quick answer

  • Network — Use case
  • bridge — Default single-host container networking.
  • custom bridge — Recommended for app containers that need DNS-based communication.
  • host — Container shares host network stack.
  • none — No network access.

List networks

docker network ls

Create a custom network

docker network create app_net

Run containers on the same network

docker run -d --name redis --network app_net redis:7 docker run -it --rm --network app_net alpine sh

Inside the Alpine container, you can reach Redis using the container name redis .

apk add --no-cache redis redis-cli -h redis ping

Port mapping

Port mapping exposes a container port on the host machine.

docker run -d --name web -p 8080:80 nginx

Here, host port 8080 maps to container port 80 .

Inspect a network

docker network inspect app_net

Connect and disconnect containers

docker network connect app_net web docker network disconnect app_net web

Common networking problems

  • Problem — Likely cause — Fix
  • Cannot access app from browser — Port not published — Use -p HOST:CONTAINER .
  • Containers cannot resolve names — Not on same custom network — Use a custom network.
  • Port already allocated — Host port already in use — Choose another host port.

Best practices

  • Use custom bridge networks for related containers.
  • Expose only required ports.
  • Use container names or Compose service names for internal communication.
  • Avoid host network unless you really need it.
  • Document port mappings clearly.

Related Melochip guides

  • Docker Learning Path
  • Docker Compose Beginner Guide
  • Kubernetes Cluster Setup Guide

Official references

  • Docker networking documentation

Did this help?

Yes No

Join the discussion

0 Comments

Ask questions, add context, or share what worked.

Sign in to join the discussion

No comments yet. Start the discussion.

More from Melochip Editorial

Related articles

Stay in the loop. Get new Melochip articles

Receive Melochip article updates when new articles are available. Explicit opt-in only.

No pre-checked boxes. Unsubscribe support is part of the subscriber foundation.