mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
300c11c7c9
This changes mounts.NewParser() to create a parser for the current operatingsystem, instead of one specific to a (possibly non-matching, in case of LCOW) OS. With the OS-specific handling being removed, the "OS" parameter is also removed from `daemon.verifyContainerSettings()`, and various other container-related functions. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
// +build linux freebsd
|
|
|
|
package daemon
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
containertypes "github.com/docker/docker/api/types/container"
|
|
"github.com/docker/docker/daemon/config"
|
|
"github.com/docker/go-connections/nat"
|
|
"gotest.tools/v3/assert"
|
|
)
|
|
|
|
// TestContainerWarningHostAndPublishPorts that a warning is returned when setting network mode to host and specifying published ports.
|
|
// This should not be tested on Windows because Windows doesn't support "host" network mode.
|
|
func TestContainerWarningHostAndPublishPorts(t *testing.T) {
|
|
testCases := []struct {
|
|
ports nat.PortMap
|
|
warnings []string
|
|
}{
|
|
{ports: nat.PortMap{}},
|
|
{ports: nat.PortMap{
|
|
"8080": []nat.PortBinding{{HostPort: "8989"}},
|
|
}, warnings: []string{"Published ports are discarded when using host network mode"}},
|
|
}
|
|
muteLogs()
|
|
|
|
for _, tc := range testCases {
|
|
hostConfig := &containertypes.HostConfig{
|
|
Runtime: "runc",
|
|
NetworkMode: "host",
|
|
PortBindings: tc.ports,
|
|
}
|
|
cs := &config.Config{
|
|
CommonUnixConfig: config.CommonUnixConfig{
|
|
Runtimes: map[string]types.Runtime{"runc": {}},
|
|
},
|
|
}
|
|
d := &Daemon{configStore: cs}
|
|
wrns, err := d.verifyContainerSettings(hostConfig, &containertypes.Config{}, false)
|
|
assert.NilError(t, err)
|
|
assert.DeepEqual(t, tc.warnings, wrns)
|
|
}
|
|
}
|