mirror of
https://github.com/containers/podman
synced 2024-10-20 01:03:51 +00:00
Merge pull request #10246 from zhangguanzhang/compose-static-ip
Fixes docker-compose cannot set static ip when use ipam
This commit is contained in:
commit
d6000a0b86
|
@ -302,6 +302,11 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup
|
|||
staticIP := net.ParseIP(ep.IPAddress)
|
||||
netInfo.StaticIP = &staticIP
|
||||
}
|
||||
// if IPAMConfig.IPv4Address is provided
|
||||
if ep.IPAMConfig != nil && ep.IPAMConfig.IPv4Address != "" {
|
||||
staticIP := net.ParseIP(ep.IPAMConfig.IPv4Address)
|
||||
netInfo.StaticIP = &staticIP
|
||||
}
|
||||
// If MAC address is provided
|
||||
if len(ep.MacAddress) > 0 {
|
||||
staticMac, err := net.ParseMAC(ep.MacAddress)
|
||||
|
|
17
test/compose/ipam_set_ip/docker-compose.yml
Normal file
17
test/compose/ipam_set_ip/docker-compose.yml
Normal file
|
@ -0,0 +1,17 @@
|
|||
version: "3.2"
|
||||
services:
|
||||
test:
|
||||
image: alpine
|
||||
networks:
|
||||
net1:
|
||||
ipv4_address: 10.123.0.253
|
||||
tty: true
|
||||
command: ["top"]
|
||||
|
||||
networks:
|
||||
net1:
|
||||
driver: bridge
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 10.123.0.0/24
|
4
test/compose/ipam_set_ip/tests.sh
Normal file
4
test/compose/ipam_set_ip/tests.sh
Normal file
|
@ -0,0 +1,4 @@
|
|||
# -*- bash -*-
|
||||
|
||||
podman container inspect ipam_set_ip_test_1 --format '{{ .NetworkSettings.Networks.ipam_set_ip_net1.IPAddress }}'
|
||||
like "$output" "10.123.0.253" "$testname : ip address is set"
|
Loading…
Reference in a new issue