aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/common/create_opts.go5
-rw-r--r--test/compose/ipam_set_ip/docker-compose.yml17
-rw-r--r--test/compose/ipam_set_ip/tests.sh4
3 files changed, 26 insertions, 0 deletions
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index ca36d751e..77ac781a5 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -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)
diff --git a/test/compose/ipam_set_ip/docker-compose.yml b/test/compose/ipam_set_ip/docker-compose.yml
new file mode 100644
index 000000000..d220c02c0
--- /dev/null
+++ b/test/compose/ipam_set_ip/docker-compose.yml
@@ -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
diff --git a/test/compose/ipam_set_ip/tests.sh b/test/compose/ipam_set_ip/tests.sh
new file mode 100644
index 000000000..ecaf3167e
--- /dev/null
+++ b/test/compose/ipam_set_ip/tests.sh
@@ -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"