NAME¶ 名称
podman-network - Manage Podman networks
podman-network - 管理 Podman 网络
SYNOPSIS¶ 概要
podman network subcommand
podman 网络子命令
DESCRIPTION¶ 描述
The network command manages networks for Podman.
网络命令用于管理 Podman 的网络。
Podman supports two network backends Netavark
and CNI. Netavark is the default network backend and was added in Podman version 4.0.
CNI is deprecated and will be removed in the next major Podman version 5.0, in preference of Netavark.
To configure the network backend use the network_backend
key under the [Network]
in
containers.conf(5).
New systems use netavark by default, to check what backend is used run
podman info --format {{.Host.NetworkBackend}}
.
Podman 支持两种网络后端 Netavark 和 CNI。Netavark 是默认的网络后端,并在 Podman 版本 4.0 中添加。CNI 已被弃用,并将在下一个主要的 Podman 版本 5.0 中移除,以 Netavark 为首选。要配置网络后端,请在 containers.conf(5)中使用 network_backend
键下的 [Network]
。新系统默认使用 netavark,要检查使用的后端,请运行 podman info --format {{.Host.NetworkBackend}}
。
All network commands work for both backends but CNI and Netavark use different config files
so networks have to be created again after a backend change.
所有网络命令对两种后端都适用,但 CNI 和 Netavark 使用不同的配置文件,因此在更改后端后必须重新创建网络。
COMMANDS¶ 命令 ¶
Command |
Man Page 手册页 |
Description |
---|---|---|
connect |
Connect a container to a network |
|
create |
Create a Podman network 创建一个 Podman 网络 |
|
disconnect |
Disconnect a container from a network |
|
exists |
Check if the given network exists |
|
inspect |
Display the network configuration for one or more networks |
|
ls |
Display a summary of networks |
|
prune |
Remove all unused networks |
|
reload |
Reload network configuration for containers |
|
rm |
Remove one or more networks |
|
update |
Update an existing Podman network |
SUBNET NOTES¶ 子网注释
Podman requires specific default IPs and, thus, network subnets. The default values used by Podman can be modified in the containers.conf(5) file.
Podman 需要特定的默认 IP 地址和网络子网。Podman 使用的默认值可以在 containers.conf(5) 文件中进行修改。
Podman network¶ Podman 网络
The default bridge network (called podman
) uses 10.88.0.0/16 as a subnet. When Podman runs as root, the podman
network is used as default. It is the same as adding the option --network bridge
or --network podman
. This subnet can be changed in containers.conf(5) under the [network] section. Set the default_subnet
to any subnet that is free in the environment. The name of the default network can also be changed from podman
to another name using the default network key. Note that this is only done when no containers are running.
默认的桥接网络(称为 podman
)使用 10.88.0.0/16 作为子网。当 Podman 以 root 身份运行时,默认使用 podman
网络。这与添加选项 --network bridge
或 --network podman
相同。此子网可以在 containers.conf(5)的[network]部分中进行更改。将 default_subnet
设置为环境中空闲的任何子网。还可以使用默认网络键将默认网络的名称从 podman
更改为其他名称。请注意,只有在没有容器运行时才会执行此操作。
Slirp4netns¶ Slirp4netns
When Podman is run as rootless, the internet connectivity is provided with slirp4netns by default. Slirp4nents uses 10.0.2.0/24 for its default network. This can also be changed in containers.conf(5) but under the [engine]
section. Use the network_cmd_options
key and add ["cidr=X.X.X.X/24"]
as a value. Note that slirp4netns needs a network prefix size between 1 and 25. This option accepts an array, so more options can be added in a comma-separated string as described on the podman-network-create(1) man page. To change the CIDR for just one container, specify it on the cli using the --network
option like this: --network slirp4netns:cidr=192.168.1.0/24
.
当 Podman 以非 root 用户身份运行时,默认情况下使用 slirp4netns 提供互联网连接。Slirp4nents 默认使用 10.0.2.0/24 作为其网络。这也可以在 containers.conf(5) 中更改,但在 [engine]
部分下。使用 network_cmd_options
键并将 ["cidr=X.X.X.X/24"]
添加为值。请注意,slirp4netns 需要网络前缀大小在 1 到 25 之间。此选项接受数组,因此可以像在 podman-network-create(1) 手册页中描述的那样,将更多选项添加为逗号分隔的字符串。要仅更改一个容器的 CIDR,请在 cli 中使用 --network
选项指定,如下所示: --network slirp4netns:cidr=192.168.1.0/24
。
When using the default network as rootless, i.e. --network podman/bridge, then it also uses the same subnet as described above in addition to the slirp4netns subnet.
当以非 root 用户身份使用默认网络,即 --network podman/bridge 时,它还使用与上述相同的子网以及 slirp4netns 子网。
Podman network create¶ Podman 网络创建 ¶
When a new network is created with a podman network create
command, and no subnet is given with the --subnet option, Podman starts picking a free subnet from 10.89.0.0/24 to 10.255.255.0/24. Use the default_subnet_pools
option under the [network]
section in containers.conf(5) to change the range and/or size that is assigned by default.
当使用 podman network create
命令创建新网络时,并且没有使用 --subnet 选项指定子网时,Podman 会从 10.89.0.0/24 到 10.255.255.0/24 中选择一个空闲子网。在 containers.conf(5) 中的 [network]
部分下使用 default_subnet_pools
选项来更改默认分配的范围和/或大小。