summaryrefslogtreecommitdiff
path: root/cmd/podman/common
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-08-04 10:20:38 +0200
committerGitHub <noreply@github.com>2020-08-04 10:20:38 +0200
commit1ed1e583a06288bb2f3058f7d4dff7650af5f3bd (patch)
treee4726cd3209526a9817c495a3765e7a5e706f494 /cmd/podman/common
parent1709335cf04e947117d4ae4dca72f24f4095511b (diff)
parent7bedff96356eb1a4c14a0c86b41a70a8d4f41950 (diff)
downloadpodman-1ed1e583a06288bb2f3058f7d4dff7650af5f3bd.tar.gz
podman-1ed1e583a06288bb2f3058f7d4dff7650af5f3bd.tar.bz2
podman-1ed1e583a06288bb2f3058f7d4dff7650af5f3bd.zip
Merge pull request #7201 from mheon/0000_is_empty
Do not set host IP on ports when 0.0.0.0 requested
Diffstat (limited to 'cmd/podman/common')
-rw-r--r--cmd/podman/common/util.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd/podman/common/util.go b/cmd/podman/common/util.go
index 41432c6f0..17e779c86 100644
--- a/cmd/podman/common/util.go
+++ b/cmd/podman/common/util.go
@@ -175,12 +175,15 @@ func parseSplitPort(hostIP, hostPort *string, ctrPort string, protocol *string)
if hostIP != nil {
if *hostIP == "" {
return newPort, errors.Errorf("must provide a non-empty container host IP to publish")
+ } else if *hostIP != "0.0.0.0" {
+ // If hostIP is 0.0.0.0, leave it unset - CNI treats
+ // 0.0.0.0 and empty differently, Docker does not.
+ testIP := net.ParseIP(*hostIP)
+ if testIP == nil {
+ return newPort, errors.Errorf("cannot parse %q as an IP address", *hostIP)
+ }
+ newPort.HostIP = testIP.String()
}
- testIP := net.ParseIP(*hostIP)
- if testIP == nil {
- return newPort, errors.Errorf("cannot parse %q as an IP address", *hostIP)
- }
- newPort.HostIP = testIP.String()
}
if hostPort != nil {
if *hostPort == "" {