2021-08-23 13:14:53 +00:00
|
|
|
//go:build !windows
|
2016-05-07 10:05:26 +00:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-04-04 13:23:19 +00:00
|
|
|
"strings"
|
2019-09-09 21:06:12 +00:00
|
|
|
"testing"
|
2016-05-07 10:05:26 +00:00
|
|
|
|
2023-07-27 10:58:10 +00:00
|
|
|
"github.com/docker/docker/integration-cli/cli"
|
2023-07-14 18:02:38 +00:00
|
|
|
"github.com/docker/docker/testutil"
|
2019-08-29 20:52:40 +00:00
|
|
|
"github.com/docker/docker/testutil/request"
|
2020-02-07 13:39:24 +00:00
|
|
|
"gotest.tools/v3/assert"
|
2016-05-07 10:05:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// #19100 This is a deprecated feature test, it should be removed in Docker 1.12
|
2019-09-09 21:05:55 +00:00
|
|
|
func (s *DockerNetworkSuite) TestDeprecatedDockerNetworkStartAPIWithHostconfig(c *testing.T) {
|
2023-07-27 10:58:10 +00:00
|
|
|
const netName = "test"
|
|
|
|
const conName = "foo"
|
|
|
|
cli.DockerCmd(c, "network", "create", netName)
|
|
|
|
cli.DockerCmd(c, "create", "--name", conName, "busybox", "top")
|
2016-05-07 10:05:26 +00:00
|
|
|
|
|
|
|
config := map[string]interface{}{
|
|
|
|
"HostConfig": map[string]interface{}{
|
|
|
|
"NetworkMode": netName,
|
|
|
|
},
|
|
|
|
}
|
2023-07-14 18:02:38 +00:00
|
|
|
_, _, err := request.Post(testutil.GetContext(c), formatV123StartAPIURL("/containers/"+conName+"/start"), request.JSONBody(config))
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2023-07-27 10:58:10 +00:00
|
|
|
cli.WaitRun(c, conName)
|
2016-05-07 10:05:26 +00:00
|
|
|
networks := inspectField(c, conName, "NetworkSettings.Networks")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.Assert(c, strings.Contains(networks, netName), "Should contain '%s' network", netName)
|
|
|
|
assert.Assert(c, !strings.Contains(networks, "bridge"), "Should not contain 'bridge' network")
|
2016-05-07 10:05:26 +00:00
|
|
|
}
|