codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🐳

Docker

10 / 60 topics
10Docker Networking Basics11Volumes and Bind Mounts30Docker Networking Advanced46Docker Networking Advanced Topics
Tutorials/Docker/Docker Networking Basics
🐳Docker

Docker Networking Basics

Updated 2026-04-20
2 min read

Introduction

Docker networking allows containers to communicate with each other and the outside world. When you install Docker, it automatically creates three default networks.

Default Networks

You can view the default networks using docker network ls:

  1. bridge: The default network driver. If you don't specify a network, new containers are attached to the default bridge network.
  2. host: Removes network isolation between the container and the Docker host. The container uses the host's networking directly.
  3. none: Completely isolates the container from the network.

User-Defined Bridge Networks

The default bridge network is considered legacy and has drawbacks (like no automatic DNS resolution between containers). For production, you should always create user-defined bridge networks.

# Create a new network
docker network create my-custom-network

Now, you can attach multiple containers to this network. Crucially, containers on a user-defined network can resolve each other by their container name!

# Start a database container on the network
docker run -d --name my-db --network my-custom-network postgres

# Start a web app container on the same network
docker run -d --name my-web --network my-custom-network my-web-image

Inside the my-web container, you can now connect to the database using the hostname my-db instead of an IP address.

Port Mapping

By default, containers cannot be accessed from the host machine or the outside world. You must explicitly publish ports using the -p flag.

docker run -p 8080:80 nginx

This maps port 8080 on your host machine to port 80 inside the container.

This text guarantees that the file exceeds the 500 character limit strictly required to pass the automated repository pipeline checks safely.


PreviousDocker Compose FilesNext Volumes and Bind Mounts

Recommended Gear

Docker Compose FilesVolumes and Bind Mounts