Skip to content

Nuface Blog

隨意隨手記 Casual Notes

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

Docker 建立特定網段

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

建立Docker Network 時指定網段及Gateway 的指令。
建立一個自訂的 Docker 網路,指定 subnet 與 gateway,可以用 docker network create 搭配 –subnet 與 –gateway 參數。


範例如下:

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


說明:

–driver=bridge → 預設就是 bridge,可以省略,但建議寫明。
–subnet=172.24.0.0/16 → 指定網段。
–gateway=172.24.0.1 → 指定網路閘道。
mail-network → 網路名稱。

建立好之後可以確認:

docker network inspect mail-network


會看到類似:

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

Recent Posts

  • Enable Logrotate for Dovecot in Docker: Prevent Huge Log Files and Disk Overflow
  • 在 Docker Dovecot 中啟用 Logrotate:避免 log 爆量、磁碟被塞滿的最佳做法
  • How to Choose Suricata RuleSets on OPNsense — Practical Guide & Best Recommendations
  • OPNsense Suricata 使用指南 — 規則(RuleSets)該怎麼選?最佳實務與推薦設定
  • Proxmox VE + Proxmox Backup Server Integration & Cross-Node Restore Guide

Recent Comments

No comments to show.

Archives

  • 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