Podman : Podman Network2019/10/11 |
This is the basic usage to configure Podman Network.
|
|
[1] | When running containers without specifying network, default [podman] network is assigned. |
# display network list [root@dlp ~]# podman network ls NAME VERSION PLUGINS podman 0.4.0 bridge,portmap,firewall,tuning # display details of [podman] [root@dlp ~]# podman network inspect podman [ { "cniVersion": "0.4.0", "name": "podman", "plugins": [ { "bridge": "cni-podman0", "hairpinMode": true, "ipMasq": true, "ipam": { "ranges": [ [ { "gateway": "10.88.0.1", "subnet": "10.88.0.0/16" } ] ], "routes": [ { "dst": "0.0.0.0/0" } ], "type": "host-local" }, "isGateway": true, "type": "bridge" }, { "capabilities": { "portMappings": true }, "type": "portmap" }, { "type": "firewall" }, { "type": "tuning" } ] } ] # [podman] is assigned as container network by default [root@dlp ~]# podman run centos /usr/sbin/ip route default via 10.88.0.1 dev eth0 10.88.0.0/16 dev eth0 proto kernel scope link src 10.88.0.7 |
[2] | If you'd like to assign another network, configure like follows. |
# create network [network01] with [192.168.100.0/24] subnet [root@dlp ~]# podman network create --subnet 192.168.100.0/24 network01 /etc/cni/net.d/network01.conflist podman network ls NAME VERSION PLUGINS podman 0.4.0 bridge,portmap,firewall,tuning network01 0.4.0 bridge,portmap,firewall,tuning # run a container with specifying [network01] [root@dlp ~]# podman run --network network01 centos /usr/sbin/ip route default via 192.168.100.1 dev eth0 192.168.100.0/24 dev eth0 proto kernel scope link src 192.168.100.4 # to attach the network to existing running container, set like follows [root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d5681a6ca157 srv.world/centos-httpd /usr/sbin/apachec... 5 seconds ago Up 4 seconds ago 0.0.0.0:8081->80/tcp kind_swirles[root@dlp ~]# podman exec d5681a6ca157 ip route default via 10.88.0.1 dev eth0 10.88.0.0/16 dev eth0 proto kernel scope link src 10.88.0.9 # attach network to specify an IP address in the subnet [root@dlp ~]# podman network connect network01 d5681a6ca157
podman exec d5681a6ca157 ip route default via 10.88.0.1 dev eth0 10.88.0.0/16 dev eth0 proto kernel scope link src 10.88.0.9 192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.5 # to disconnect the network, set like follows [root@dlp ~]# podman network disconnect network01 d5681a6ca157 [root@dlp ~]# podman exec d5681a6ca157 ip route default via 10.88.0.1 dev eth0 10.88.0.0/16 dev eth0 proto kernel scope link src 10.88.0.9 |
[3] | To remove podman networks, set like follows. |
[root@dlp ~]# podman network ls NAME VERSION PLUGINS podman 0.4.0 bridge,portmap,firewall,tuning network01 0.4.0 bridge,portmap,firewall,tuning # remove [network01] [root@dlp ~]# podman network rm network01 Error: "network01" has associated containers with it. Use -f to forcibly delete containers and pods: network is being used # force remove containers with [-f] option [root@dlp ~]# podman network rm -f network01 network01 |
Sponsored Link |
|