docker_deprecated_api_v124_unix_test.go 1020 B

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