summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-04-13 15:40:51 -0400
committerGitHub <noreply@github.com>2022-04-13 15:40:51 -0400
commit480bc83b804467086e0878653d87bf51a4791980 (patch)
treeea109883ffd70c59d1c25e989da707cbf0d0e921
parentb962fb9f2929cedbacfdaaf1574300acaa1e8a00 (diff)
parent970c8d4724d0a3d24be5736e09dd37c8644c64b1 (diff)
downloadpodman-480bc83b804467086e0878653d87bf51a4791980.tar.gz
podman-480bc83b804467086e0878653d87bf51a4791980.tar.bz2
podman-480bc83b804467086e0878653d87bf51a4791980.zip
Merge pull request #13844 from Luap99/compat-netmode
compat api: use network mode bridge as default
-rw-r--r--cmd/podman/common/create_opts.go9
-rw-r--r--test/apiv2/20-containers.at13
2 files changed, 9 insertions, 13 deletions
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index 39146f918..7b7626040 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -164,8 +164,13 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
}
}
- // netMode
- nsmode, networks, netOpts, err := specgen.ParseNetworkFlag([]string{string(cc.HostConfig.NetworkMode)})
+ // special case for NetworkMode, the podman default is slirp4netns for
+ // rootless but for better docker compat we want bridge.
+ netmode := string(cc.HostConfig.NetworkMode)
+ if netmode == "" || netmode == "default" {
+ netmode = "bridge"
+ }
+ nsmode, networks, netOpts, err := specgen.ParseNetworkFlag([]string{netmode})
if err != nil {
return nil, nil, err
}
diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at
index a3675d40a..2d5754077 100644
--- a/test/apiv2/20-containers.at
+++ b/test/apiv2/20-containers.at
@@ -239,16 +239,11 @@ t GET containers/$cid/json 200 \
t POST containers/create Image=$IMAGE Entrypoint='["top"]' 201 \
.Id~[0-9a-f]\\{64\\}
cid_top=$(jq -r '.Id' <<<"$output")
-# .Network is N/A when rootless
-network_expect=
-if root; then
- network_expect='.NetworkSettings.Networks.podman.NetworkID=podman'
-fi
t GET containers/${cid_top}/json 200 \
.Config.Entrypoint[0]="top" \
.Config.Cmd='[]' \
.Path="top" \
- $network_expect
+ .NetworkSettings.Networks.podman.NetworkID=podman
t POST containers/${cid_top}/start 204
# make sure the container is running
t GET containers/${cid_top}/json 200 \
@@ -372,15 +367,11 @@ t GET containers/$cid/json 200 \
t DELETE containers/$cid?v=true 204
# Test Compat Create with default network mode (#10569)
-networkmode=slirp4netns
-if root; then
- networkmode=bridge
-fi
t POST containers/create Image=$IMAGE HostConfig='{"NetworkMode":"default"}' 201 \
.Id~[0-9a-f]\\{64\\}
cid=$(jq -r '.Id' <<<"$output")
t GET containers/$cid/json 200 \
- .HostConfig.NetworkMode="$networkmode"
+ .HostConfig.NetworkMode="bridge"
t DELETE containers/$cid?v=true 204