From c0de4a4d70a68e5afeb70a5f6c5c5fbd2ca0bcc2 Mon Sep 17 00:00:00 2001 From: zhangguanzhang Date: Thu, 6 May 2021 18:52:45 +0800 Subject: Fixes docker-compose cannot set static ip when use ipam Signed-off-by: zhangguanzhang --- cmd/podman/common/create_opts.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cmd') 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) -- cgit v1.2.3-54-g00ecf