mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
Parse slirp4netns net options with compat api
Parse the slirp4netns network options when called via compat api. The options must be extracted from the NetworkMode string. Fixes #10110 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
This commit is contained in:
@ -252,9 +252,11 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
netNS := specgen.Namespace{
|
var netOpts map[string][]string
|
||||||
NSMode: nsmode.NSMode,
|
parts := strings.SplitN(string(cc.HostConfig.NetworkMode), ":", 2)
|
||||||
Value: nsmode.Value,
|
if len(parts) > 1 {
|
||||||
|
netOpts = make(map[string][]string)
|
||||||
|
netOpts[parts[0]] = strings.Split(parts[1], ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
// network
|
// network
|
||||||
@ -265,8 +267,9 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup
|
|||||||
DNSOptions: cc.HostConfig.DNSOptions,
|
DNSOptions: cc.HostConfig.DNSOptions,
|
||||||
DNSSearch: cc.HostConfig.DNSSearch,
|
DNSSearch: cc.HostConfig.DNSSearch,
|
||||||
DNSServers: dns,
|
DNSServers: dns,
|
||||||
Network: netNS,
|
Network: nsmode,
|
||||||
PublishPorts: specPorts,
|
PublishPorts: specPorts,
|
||||||
|
NetworkOptions: netOpts,
|
||||||
}
|
}
|
||||||
|
|
||||||
// network names
|
// network names
|
||||||
|
5
test/compose/slirp4netns_opts/docker-compose.yml
Normal file
5
test/compose/slirp4netns_opts/docker-compose.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
services:
|
||||||
|
alpine:
|
||||||
|
image: alpine
|
||||||
|
network_mode: "slirp4netns:allow_host_loopback=true"
|
||||||
|
command: sh -c "echo teststring | nc 10.0.2.2 5001"
|
8
test/compose/slirp4netns_opts/setup.sh
Normal file
8
test/compose/slirp4netns_opts/setup.sh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# -*- bash -*-
|
||||||
|
|
||||||
|
# create tempfile to store nc output
|
||||||
|
OUTFILE=$(mktemp)
|
||||||
|
# listen on a port, the container will try to connect to it
|
||||||
|
nc -l 5001 > $OUTFILE &
|
||||||
|
|
||||||
|
nc_pid=$!
|
4
test/compose/slirp4netns_opts/teardown.sh
Normal file
4
test/compose/slirp4netns_opts/teardown.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# -*- bash -*-
|
||||||
|
|
||||||
|
kill $nc_pid &> /dev/null
|
||||||
|
rm -f $OUTFILE
|
6
test/compose/slirp4netns_opts/tests.sh
Normal file
6
test/compose/slirp4netns_opts/tests.sh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# -*- bash -*-
|
||||||
|
|
||||||
|
output="$(cat $OUTFILE)"
|
||||||
|
expected="teststring"
|
||||||
|
|
||||||
|
is "$output" "$expected" "$testname : nc received teststring"
|
Reference in New Issue
Block a user