You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker中--net与--network参数的区别及使用原因咨询

Docker --net vs --network: What's the Difference?

Great question — this is a common point of confusion, especially since Docker's --help output only calls out the longer --network flag. Let me clear this up for you:

  • They are exactly the same parameter — --net is just a shorthand (alias) for --network. Docker provides shorter versions of many flags to make command-line usage quicker and more concise for frequent users.
  • When you use either flag, you're configuring the network mode for a Docker container. For example, these two commands do precisely the same thing:
    docker run --net=host nginx
    docker run --network=host nginx
    
  • The reason you only see --network in the --help output is that Docker prioritizes documenting the full, standardized flag name in official help text and documentation, while keeping the shorthand available for users who prefer brevity or have old scripts relying on it.
  • This shorthand compatibility is intentional — it ensures backward compatibility with older Docker command scripts that were written using --net before the full --network flag was formally standardized.

So in short: there’s no functional difference at all, just two ways to write the exact same configuration option.

内容的提问来源于stack exchange,提问作者Mohamed Benkedadra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:59:57