docker_deprecated_api_v124_unix_test.go 1002 B

12345678910111213141516171819202122232425262728293031
  1. // +build !windows
  2. package main
  3. import (
  4. "strings"
  5. "testing"
  6. "github.com/docker/docker/internal/test/request"
  7. "gotest.tools/assert"
  8. )
  9. // #19100 This is a deprecated feature test, it should be removed in Docker 1.12
  10. func (s *DockerNetworkSuite) TestDeprecatedDockerNetworkStartAPIWithHostconfig(c *testing.T) {
  11. netName := "test"
  12. conName := "foo"
  13. dockerCmd(c, "network", "create", netName)
  14. dockerCmd(c, "create", "--name", conName, "busybox", "top")
  15. config := map[string]interface{}{
  16. "HostConfig": map[string]interface{}{
  17. "NetworkMode": netName,
  18. },
  19. }
  20. _, _, err := request.Post(formatV123StartAPIURL("/containers/"+conName+"/start"), request.JSONBody(config))
  21. assert.NilError(c, err)
  22. assert.NilError(c, waitRun(conName))
  23. networks := inspectField(c, conName, "NetworkSettings.Networks")
  24. assert.Assert(c, strings.Contains(networks, netName), "Should contain '%s' network", netName)
  25. assert.Assert(c, !strings.Contains(networks, "bridge"), "Should not contain 'bridge' network")
  26. }