Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Docker

Docker: Understand Container Networking Modes

- 20.06.26 - ErcanOPAK

🌐 Containers Need to Communicate

Default bridge works. Different network modes suit different needs. Bridge (default), Host (no isolation), None (isolated).

📝 Network Modes

Bridge (default):
- Container gets private IP
- Access via port mapping (-p 80:8080)
- Good for most containers

Host:
- Container uses host network stack
- No port mapping needed
- Performance (no NAT)
- Security risk (no isolation)

None:
- No network access
- Completely isolated
- For offline processing

Container:
- Share network with another container
- Use same IP
- Good for sidecar patterns

🎯 Examples

# Bridge (default)
docker run -d --name web -p 80:8080 nginx

# Host (no isolation)
docker run -d --name web --network host nginx

# None (isolated)
docker run -d --name offline --network none alpine sleep 1000

# Container (share network)
docker run -d --name redis redis
docker run -d --name app --network container:redis node app

# Create custom bridge network
docker network create mynet
docker run -d --network mynet --name db postgres
docker run -d --network mynet --name app myapp

💡 When to Use Which

  • Bridge: Most use cases, default
  • Host: High-performance, but less secure
  • None: Security-sensitive, offline processing
  • Container: Sidecar, proxy, service mesh
  • Custom bridge: Better isolation, container name resolution

“App couldn’t connect to DB. Switched to custom bridge network. Container name resolution worked. Network modes are essential for multi-container apps.”

— Docker User

Related posts:

Docker Images Work but Are Hard to Maintain

Docker — Layer Order Can Double Image Size

Docker: Understand Image Layers for Optimization

Post Views: 3

Post navigation

Kubernetes: Use Persistent Volumes for Data Storage
AI Prompt: Generate SWOT Analysis for Your Business or Project

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

July 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jun    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (960)
  • How to add default value for Entity Framework migrations for DateTime and Bool (898)
  • How to make theater mode the default for Youtube (857)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (814)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (597)
  • Add Constraint to SQL Table to ensure email contains @ (582)
  • Average of all values in a column that are not zero in SQL (545)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (512)
  • Find numbers with more than two decimal places in SQL (460)

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes
  • Ajax: Use Axios for HTTP Requests
  • JavaScript: Understand Hoisting
  • HTML: Use Web Storage for Client-Side Data
  • CSS: Use Filter Effects for Visual Magic
  • Windows 11: Unlock God Mode for All Settings

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (960)
  • How to add default value for Entity Framework migrations for DateTime and Bool (898)
  • How to make theater mode the default for Youtube (857)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (814)

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com