Skip to content

Nuface Blog

隨意隨手記 Casual Notes

Menu
  • Home
  • About
  • Services
  • Blog
  • Contact
  • Privacy Policy
  • Login
Menu

Docker Network Create

Posted on 2025-10-302025-10-30 by Rico

When creating a Docker network, you can specify a custom subnet and gateway using the docker network create command with the --subnet and --gateway parameters.


🧩 Example Command

docker network create \
--driver=bridge \
--subnet=172.24.0.0/16 \
--gateway=172.24.0.1 \
mail-network

🔍 Explanation

ParameterDescription
--driver=bridgeSpecifies the network driver. The default is bridge. While optional, it’s good practice to include it explicitly.
--subnet=172.24.0.0/16Defines the IP subnet for the custom Docker network.
--gateway=172.24.0.1Sets the gateway address for the network.
mail-networkThe name of the Docker network being created.

✅ Verify the Network

After creation, check the network details with:

docker network inspect mail-network

You’ll see output similar to:

"IPAM": {
    "Config": [
        {
            "Subnet": "172.24.0.0/16",
            "Gateway": "172.24.0.1"
        }
    ]
}

💡 Notes

  • This setup is useful when you need containers to communicate in a predictable private IP range.
  • You can attach containers to this custom network using --network mail-network when running or creating them.
  • To list all existing Docker networks, use: docker network ls

In summary:
To create a Docker bridge network with a specific IP range and gateway, use
docker network create --subnet=<CIDR> --gateway=<IP> <network_name>.
This allows precise control over container networking in your environment.

Recent Posts

  • Postfix + Let’s Encrypt + BIND9 + DANE Fully Automated TLSA Update Guide
  • Postfix + Let’s Encrypt + BIND9 + DANE TLSA 指紋自動更新完整教學
  • Deploying DANE in Postfix
  • 如何在 Postfix 中部署 DANE
  • DANE: DNSSEC-Based TLS Protection

Recent Comments

  1. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on High Availability Architecture, Failover, GeoDNS, Monitoring, and Email Abuse Automation (SOAR)
  2. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on MariaDB + PostfixAdmin: The Core of Virtual Domain & Mailbox Management
  3. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Daily Operations, Monitoring, and Performance Tuning for an Enterprise Mail System
  4. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Final Chapter: Complete Troubleshooting Guide & Frequently Asked Questions (FAQ)
  5. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Network Architecture, DNS Configuration, TLS Design, and Postfix/Dovecot SNI Explained

Archives

  • December 2025
  • November 2025
  • October 2025

Categories

  • AI
  • Apache
  • Cybersecurity
  • Database
  • DNS
  • Docker
  • Fail2Ban
  • FileSystem
  • Firewall
  • Linux
  • LLM
  • Mail
  • N8N
  • OpenLdap
  • OPNsense
  • PHP
  • QoS
  • Samba
  • Switch
  • Virtualization
  • VPN
  • WordPress
© 2025 Nuface Blog | Powered by Superbs Personal Blog theme