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 —
--netis 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
--networkin the--helpoutput 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
--netbefore the full--networkflag 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
相关产品推荐
相关产品推荐

