2016-05-07 06:05:26 -04:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-04-04 09:23:19 -04:00
|
|
|
"strings"
|
2019-09-09 17:06:12 -04:00
|
|
|
"testing"
|
2016-05-07 06:05:26 -04:00
|
|
|
|
2019-08-29 16:52:40 -04:00
|
|
|
"github.com/docker/docker/testutil/request"
|
2020-02-07 08:39:24 -05:00
|
|
|
"gotest.tools/v3/assert"
|
2016-05-07 06:05:26 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// #19100 This is a deprecated feature test, it should be removed in Docker 1.12
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerNetworkSuite) TestDeprecatedDockerNetworkStartAPIWithHostconfig(c *testing.T) {
|
2016-05-07 06:05:26 -04: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-23 23:56:26 -04:00
|
|
|
_, _, err := request.Post(formatV123StartAPIURL("/containers/"+conName+"/start"), request.JSONBody(config))
|
2019-04-04 09:23:19 -04:00
|
|
|
assert.NilError(c, err)
|
|
|
|
assert.NilError(c, waitRun(conName))
|
2016-05-07 06:05:26 -04:00
|
|
|
networks := inspectField(c, conName, "NetworkSettings.Networks")
|
2019-04-04 09:23:19 -04: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 06:05:26 -04:00
|
|
|
}
|