Merge pull request #10122 from Luap99/fix-10110
Parse slirp4netns net options with compat api
This commit is contained in:
commit
feac25f722
|
|
@ -252,21 +252,24 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
netNS := specgen.Namespace{
|
||||
NSMode: nsmode.NSMode,
|
||||
Value: nsmode.Value,
|
||||
var netOpts map[string][]string
|
||||
parts := strings.SplitN(string(cc.HostConfig.NetworkMode), ":", 2)
|
||||
if len(parts) > 1 {
|
||||
netOpts = make(map[string][]string)
|
||||
netOpts[parts[0]] = strings.Split(parts[1], ",")
|
||||
}
|
||||
|
||||
// network
|
||||
// Note: we cannot emulate compat exactly here. we only allow specifics of networks to be
|
||||
// defined when there is only one network.
|
||||
netInfo := entities.NetOptions{
|
||||
AddHosts: cc.HostConfig.ExtraHosts,
|
||||
DNSOptions: cc.HostConfig.DNSOptions,
|
||||
DNSSearch: cc.HostConfig.DNSSearch,
|
||||
DNSServers: dns,
|
||||
Network: netNS,
|
||||
PublishPorts: specPorts,
|
||||
AddHosts: cc.HostConfig.ExtraHosts,
|
||||
DNSOptions: cc.HostConfig.DNSOptions,
|
||||
DNSSearch: cc.HostConfig.DNSSearch,
|
||||
DNSServers: dns,
|
||||
Network: nsmode,
|
||||
PublishPorts: specPorts,
|
||||
NetworkOptions: netOpts,
|
||||
}
|
||||
|
||||
// network names
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -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=$!
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# -*- bash -*-
|
||||
|
||||
kill $nc_pid &> /dev/null
|
||||
rm -f $OUTFILE
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# -*- bash -*-
|
||||
|
||||
output="$(cat $OUTFILE)"
|
||||
expected="teststring"
|
||||
|
||||
is "$output" "$expected" "$testname : nc received teststring"
|
||||
Loading…
Reference in New Issue