# 附录：网络 network

[network官方文档](https://docs.docker.com/engine/reference/commandline/network/#usage)

首先使用`docker network ls`看一下，默认会创建 桥接模式bridge

**比如：**

当你启动了一个没有指定网络的compose，则会建立一个默认的mycompose\_default 的网络。使用下面的命令查看网络详情。

```
docker network inspect mycompose_default
```

当我们启动容器时，默认会加入bridge这个网络。

**示例创建一个简单的网络**

最简单语法

```
docker network create -d bridge mynginx
```

让我们启动容器时就可以加入`docker run-d--network=mynginx 容器名`，这时创建的容器会加入这个网络

设置子网 地址

```
docke rnetwork create -d bridge--subnet=192.128.0.0/16 mynginx
```

`http://tool.chinaz.com/Tools/subnetmask`这里有个子网掩码的计算地址

![](/files/-LfnTK7yYbc3-xx36vcW)

![](/files/-LfnTK8-Rwbn8JeBxZsA)

## 资料

[Docker的4种网络模式](https://www.cnblogs.com/gispathfinder/p/5871043.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docker.shujuwajue.com/docker-ji-qun/fu-lu-ff1a-wang-luo-network.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
