2016-05-07 10:05:26 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
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
|
|
|
|
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) {
|
2016-05-07 10:05:26 +00:00
|
|
|
netName := "test"
|
|
|
|
conName := "foo"
|
|
|
|
dockerCmd(c, "network", "create", netName)
|
|
|
|
dockerCmd(c, "create", "--name", conName, "busybox", "top")
|
|
|
|
|
|
|
|
config := map[string]interface{}{
|
|
|
|
"HostConfig": map[string]interface{}{
|
|
|
|
"NetworkMode": netName,
|
|
|
|
},
|
|
|
|
}
|
2017-05-24 03:56:26 +00:00
|
|
|
_, _, err := request.Post(formatV123StartAPIURL("/containers/"+conName+"/start"), request.JSONBody(config))
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
|
|
|
assert.NilError(c, waitRun(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
|
|
|
}
|