|
@@ -17,9 +17,9 @@ import (
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/api/types"
|
|
- containertypes "github.com/docker/docker/api/types/container"
|
|
|
|
- mounttypes "github.com/docker/docker/api/types/mount"
|
|
|
|
- networktypes "github.com/docker/docker/api/types/network"
|
|
|
|
|
|
+ "github.com/docker/docker/api/types/container"
|
|
|
|
+ "github.com/docker/docker/api/types/mount"
|
|
|
|
+ "github.com/docker/docker/api/types/network"
|
|
"github.com/docker/docker/api/types/versions"
|
|
"github.com/docker/docker/api/types/versions"
|
|
"github.com/docker/docker/client"
|
|
"github.com/docker/docker/client"
|
|
dconfig "github.com/docker/docker/daemon/config"
|
|
dconfig "github.com/docker/docker/daemon/config"
|
|
@@ -476,7 +476,7 @@ func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Labels: map[string]string{"key1": "value1", "key2": "value2"}}
|
|
Labels: map[string]string{"key1": "value1", "key2": "value2"}}
|
|
|
|
|
|
options := types.ContainerCommitOptions{
|
|
options := types.ContainerCommitOptions{
|
|
@@ -504,12 +504,12 @@ func (s *DockerSuite) TestContainerAPIBadPort(c *testing.T) {
|
|
// TODO Windows to Windows CI - Port this test
|
|
// TODO Windows to Windows CI - Port this test
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
|
|
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
Cmd: []string{"/bin/sh", "-c", "echo test"},
|
|
Cmd: []string{"/bin/sh", "-c", "echo test"},
|
|
}
|
|
}
|
|
|
|
|
|
- hostConfig := containertypes.HostConfig{
|
|
|
|
|
|
+ hostConfig := container.HostConfig{
|
|
PortBindings: nat.PortMap{
|
|
PortBindings: nat.PortMap{
|
|
"8080/tcp": []nat.PortBinding{
|
|
"8080/tcp": []nat.PortBinding{
|
|
{
|
|
{
|
|
@@ -523,12 +523,12 @@ func (s *DockerSuite) TestContainerAPIBadPort(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
|
|
assert.ErrorContains(c, err, `invalid port specification: "aa80"`)
|
|
assert.ErrorContains(c, err, `invalid port specification: "aa80"`)
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestContainerAPICreate(c *testing.T) {
|
|
func (s *DockerSuite) TestContainerAPICreate(c *testing.T) {
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
Cmd: []string{"/bin/sh", "-c", "touch /test && ls /test"},
|
|
Cmd: []string{"/bin/sh", "-c", "touch /test && ls /test"},
|
|
}
|
|
}
|
|
@@ -537,7 +537,7 @@ func (s *DockerSuite) TestContainerAPICreate(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ container, err := cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
out, _ := dockerCmd(c, "start", "-a", container.ID)
|
|
out, _ := dockerCmd(c, "start", "-a", container.ID)
|
|
@@ -550,7 +550,7 @@ func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &containertypes.Config{}, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &container.Config{}, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
expected := "No command specified"
|
|
expected := "No command specified"
|
|
assert.ErrorContains(c, err, expected)
|
|
assert.ErrorContains(c, err, expected)
|
|
@@ -558,12 +558,12 @@ func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *testing.T) {
|
|
|
|
|
|
func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T) {
|
|
func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T) {
|
|
// Container creation must fail if client specified configurations for more than one network
|
|
// Container creation must fail if client specified configurations for more than one network
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
}
|
|
}
|
|
|
|
|
|
- networkingConfig := networktypes.NetworkingConfig{
|
|
|
|
- EndpointsConfig: map[string]*networktypes.EndpointSettings{
|
|
|
|
|
|
+ networkingConfig := network.NetworkingConfig{
|
|
|
|
+ EndpointsConfig: map[string]*network.EndpointSettings{
|
|
"net1": {},
|
|
"net1": {},
|
|
"net2": {},
|
|
"net2": {},
|
|
"net3": {},
|
|
"net3": {},
|
|
@@ -574,7 +574,7 @@ func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T)
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networkingConfig, nil, "")
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &networkingConfig, nil, "")
|
|
msg := err.Error()
|
|
msg := err.Error()
|
|
// network name order in error message is not deterministic
|
|
// network name order in error message is not deterministic
|
|
assert.Assert(c, strings.Contains(msg, "Container cannot be connected to network endpoints"))
|
|
assert.Assert(c, strings.Contains(msg, "Container cannot be connected to network endpoints"))
|
|
@@ -596,12 +596,12 @@ func (s *DockerSuite) TestContainerAPICreateOtherNetworkModes(c *testing.T) {
|
|
UtilCreateNetworkMode(c, "container:web1")
|
|
UtilCreateNetworkMode(c, "container:web1")
|
|
}
|
|
}
|
|
|
|
|
|
-func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode) {
|
|
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+func UtilCreateNetworkMode(c *testing.T, networkMode container.NetworkMode) {
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
}
|
|
}
|
|
|
|
|
|
- hostConfig := containertypes.HostConfig{
|
|
|
|
|
|
+ hostConfig := container.HostConfig{
|
|
NetworkMode: networkMode,
|
|
NetworkMode: networkMode,
|
|
}
|
|
}
|
|
|
|
|
|
@@ -609,7 +609,7 @@ func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode)
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
@@ -621,12 +621,12 @@ func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode)
|
|
func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
|
|
func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
|
|
// TODO Windows to Windows CI. The CpuShares part could be ported.
|
|
// TODO Windows to Windows CI. The CpuShares part could be ported.
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
}
|
|
}
|
|
|
|
|
|
- hostConfig := containertypes.HostConfig{
|
|
|
|
- Resources: containertypes.Resources{
|
|
|
|
|
|
+ hostConfig := container.HostConfig{
|
|
|
|
+ Resources: container.Resources{
|
|
CPUShares: 512,
|
|
CPUShares: 512,
|
|
CpusetCpus: "0",
|
|
CpusetCpus: "0",
|
|
},
|
|
},
|
|
@@ -636,7 +636,7 @@ func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
@@ -913,8 +913,8 @@ func (s *DockerSuite) TestContainerAPIRestart(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- timeout := 1 * time.Second
|
|
|
|
- err = cli.ContainerRestart(context.Background(), name, &timeout)
|
|
|
|
|
|
+ timeout := 1
|
|
|
|
+ err = cli.ContainerRestart(context.Background(), name, container.StopOptions{Timeout: &timeout})
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second) == nil)
|
|
assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second) == nil)
|
|
@@ -930,7 +930,7 @@ func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- err = cli.ContainerRestart(context.Background(), name, nil)
|
|
|
|
|
|
+ err = cli.ContainerRestart(context.Background(), name, container.StopOptions{})
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second) == nil)
|
|
assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second) == nil)
|
|
@@ -938,7 +938,7 @@ func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) {
|
|
|
|
|
|
func (s *DockerSuite) TestContainerAPIStart(c *testing.T) {
|
|
func (s *DockerSuite) TestContainerAPIStart(c *testing.T) {
|
|
name := "testing-start"
|
|
name := "testing-start"
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
Cmd: append([]string{"/bin/sh", "-c"}, sleepCommandForDaemonPlatform()...),
|
|
Cmd: append([]string{"/bin/sh", "-c"}, sleepCommandForDaemonPlatform()...),
|
|
OpenStdin: true,
|
|
OpenStdin: true,
|
|
@@ -948,7 +948,7 @@ func (s *DockerSuite) TestContainerAPIStart(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, name)
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, name)
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{})
|
|
err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{})
|
|
@@ -965,19 +965,23 @@ func (s *DockerSuite) TestContainerAPIStart(c *testing.T) {
|
|
func (s *DockerSuite) TestContainerAPIStop(c *testing.T) {
|
|
func (s *DockerSuite) TestContainerAPIStop(c *testing.T) {
|
|
name := "test-api-stop"
|
|
name := "test-api-stop"
|
|
runSleepingContainer(c, "-i", "--name", name)
|
|
runSleepingContainer(c, "-i", "--name", name)
|
|
- timeout := 30 * time.Second
|
|
|
|
|
|
+ timeout := 30
|
|
|
|
|
|
cli, err := client.NewClientWithOpts(client.FromEnv)
|
|
cli, err := client.NewClientWithOpts(client.FromEnv)
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- err = cli.ContainerStop(context.Background(), name, &timeout)
|
|
|
|
|
|
+ err = cli.ContainerStop(context.Background(), name, container.StopOptions{
|
|
|
|
+ Timeout: &timeout,
|
|
|
|
+ })
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
assert.Assert(c, waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second) == nil)
|
|
assert.Assert(c, waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second) == nil)
|
|
|
|
|
|
// second call to start should give 304
|
|
// second call to start should give 304
|
|
// maybe add ContainerStartWithRaw to test it
|
|
// maybe add ContainerStartWithRaw to test it
|
|
- err = cli.ContainerStop(context.Background(), name, &timeout)
|
|
|
|
|
|
+ err = cli.ContainerStop(context.Background(), name, container.StopOptions{
|
|
|
|
+ Timeout: &timeout,
|
|
|
|
+ })
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1255,14 +1259,14 @@ func (s *DockerSuite) TestContainerAPIPostContainerStop(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- err = cli.ContainerStop(context.Background(), containerID, nil)
|
|
|
|
|
|
+ err = cli.ContainerStop(context.Background(), containerID, container.StopOptions{})
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
assert.Assert(c, waitInspect(containerID, "{{ .State.Running }}", "false", 60*time.Second) == nil)
|
|
assert.Assert(c, waitInspect(containerID, "{{ .State.Running }}", "false", 60*time.Second) == nil)
|
|
}
|
|
}
|
|
|
|
|
|
// #14170
|
|
// #14170
|
|
func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *testing.T) {
|
|
func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *testing.T) {
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
Entrypoint: []string{"echo"},
|
|
Entrypoint: []string{"echo"},
|
|
Cmd: []string{"hello", "world"},
|
|
Cmd: []string{"hello", "world"},
|
|
@@ -1272,7 +1276,7 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *t
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "echotest")
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "echotest")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
out, _ := dockerCmd(c, "start", "-a", "echotest")
|
|
out, _ := dockerCmd(c, "start", "-a", "echotest")
|
|
assert.Equal(c, strings.TrimSpace(out), "hello world")
|
|
assert.Equal(c, strings.TrimSpace(out), "hello world")
|
|
@@ -1290,7 +1294,7 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *t
|
|
|
|
|
|
// #14170
|
|
// #14170
|
|
func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T) {
|
|
func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T) {
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
Cmd: []string{"echo", "hello", "world"},
|
|
Cmd: []string{"echo", "hello", "world"},
|
|
}
|
|
}
|
|
@@ -1299,7 +1303,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T)
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "echotest")
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "echotest")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
out, _ := dockerCmd(c, "start", "-a", "echotest")
|
|
out, _ := dockerCmd(c, "start", "-a", "echotest")
|
|
assert.Equal(c, strings.TrimSpace(out), "hello world")
|
|
assert.Equal(c, strings.TrimSpace(out), "hello world")
|
|
@@ -1330,10 +1334,10 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *tes
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
assert.Equal(c, res.StatusCode, http.StatusCreated)
|
|
assert.Equal(c, res.StatusCode, http.StatusCreated)
|
|
|
|
|
|
- config2 := containertypes.Config{
|
|
|
|
|
|
+ config2 := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
}
|
|
}
|
|
- hostConfig := containertypes.HostConfig{
|
|
|
|
|
|
+ hostConfig := container.HostConfig{
|
|
CapAdd: []string{"net_admin", "SYS_ADMIN"},
|
|
CapAdd: []string{"net_admin", "SYS_ADMIN"},
|
|
CapDrop: []string{"SETGID", "CAP_SETPCAP"},
|
|
CapDrop: []string{"SETGID", "CAP_SETPCAP"},
|
|
}
|
|
}
|
|
@@ -1342,21 +1346,21 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *tes
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config2, &hostConfig, &networktypes.NetworkingConfig{}, nil, "capaddtest1")
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config2, &hostConfig, &network.NetworkingConfig{}, nil, "capaddtest1")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
}
|
|
}
|
|
|
|
|
|
// #14915
|
|
// #14915
|
|
func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *testing.T) {
|
|
func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *testing.T) {
|
|
testRequires(c, DaemonIsLinux) // Windows only support 1.25 or later
|
|
testRequires(c, DaemonIsLinux) // Windows only support 1.25 or later
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
}
|
|
}
|
|
|
|
|
|
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.18"))
|
|
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.18"))
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1397,27 +1401,27 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *testing.T
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
}
|
|
}
|
|
- hostConfig1 := containertypes.HostConfig{
|
|
|
|
- Resources: containertypes.Resources{
|
|
|
|
|
|
+ hostConfig1 := container.HostConfig{
|
|
|
|
+ Resources: container.Resources{
|
|
CpusetCpus: "1-42,,",
|
|
CpusetCpus: "1-42,,",
|
|
},
|
|
},
|
|
}
|
|
}
|
|
name := "wrong-cpuset-cpus"
|
|
name := "wrong-cpuset-cpus"
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig1, &networktypes.NetworkingConfig{}, nil, name)
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig1, &network.NetworkingConfig{}, nil, name)
|
|
expected := "Invalid value 1-42,, for cpuset cpus"
|
|
expected := "Invalid value 1-42,, for cpuset cpus"
|
|
assert.ErrorContains(c, err, expected)
|
|
assert.ErrorContains(c, err, expected)
|
|
|
|
|
|
- hostConfig2 := containertypes.HostConfig{
|
|
|
|
- Resources: containertypes.Resources{
|
|
|
|
|
|
+ hostConfig2 := container.HostConfig{
|
|
|
|
+ Resources: container.Resources{
|
|
CpusetMems: "42-3,1--",
|
|
CpusetMems: "42-3,1--",
|
|
},
|
|
},
|
|
}
|
|
}
|
|
name = "wrong-cpuset-mems"
|
|
name = "wrong-cpuset-mems"
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig2, &networktypes.NetworkingConfig{}, nil, name)
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig2, &network.NetworkingConfig{}, nil, name)
|
|
expected = "Invalid value 42-3,1-- for cpuset mems"
|
|
expected = "Invalid value 42-3,1-- for cpuset mems"
|
|
assert.ErrorContains(c, err, expected)
|
|
assert.ErrorContains(c, err, expected)
|
|
}
|
|
}
|
|
@@ -1425,10 +1429,10 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *testing.T
|
|
func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *testing.T) {
|
|
func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *testing.T) {
|
|
// ShmSize is not supported on Windows
|
|
// ShmSize is not supported on Windows
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
}
|
|
}
|
|
- hostConfig := containertypes.HostConfig{
|
|
|
|
|
|
+ hostConfig := container.HostConfig{
|
|
ShmSize: -1,
|
|
ShmSize: -1,
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1436,7 +1440,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
|
|
assert.ErrorContains(c, err, "SHM size can not be less than 0")
|
|
assert.ErrorContains(c, err, "SHM size can not be less than 0")
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1444,7 +1448,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testin
|
|
// ShmSize is not supported on Windows
|
|
// ShmSize is not supported on Windows
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
|
|
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
Cmd: []string{"mount"},
|
|
Cmd: []string{"mount"},
|
|
}
|
|
}
|
|
@@ -1453,7 +1457,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testin
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ container, err := cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
@@ -1471,7 +1475,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testin
|
|
func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
|
|
func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
|
|
// ShmSize is not supported on Windows
|
|
// ShmSize is not supported on Windows
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
Cmd: []string{"mount"},
|
|
Cmd: []string{"mount"},
|
|
}
|
|
}
|
|
@@ -1480,7 +1484,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ container, err := cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
@@ -1498,12 +1502,12 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
|
|
func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
|
|
func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
|
|
// ShmSize is not supported on Windows
|
|
// ShmSize is not supported on Windows
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
Cmd: []string{"mount"},
|
|
Cmd: []string{"mount"},
|
|
}
|
|
}
|
|
|
|
|
|
- hostConfig := containertypes.HostConfig{
|
|
|
|
|
|
+ hostConfig := container.HostConfig{
|
|
ShmSize: 1073741824,
|
|
ShmSize: 1073741824,
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1511,7 +1515,7 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ container, err := cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
@@ -1529,7 +1533,7 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
|
|
func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(c *testing.T) {
|
|
func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(c *testing.T) {
|
|
// Swappiness is not supported on Windows
|
|
// Swappiness is not supported on Windows
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1537,7 +1541,7 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- container, err := cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ container, err := cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, "")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
|
@@ -1555,11 +1559,11 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *tes
|
|
// OomScoreAdj is not supported on Windows
|
|
// OomScoreAdj is not supported on Windows
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
|
|
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
}
|
|
}
|
|
|
|
|
|
- hostConfig := containertypes.HostConfig{
|
|
|
|
|
|
+ hostConfig := container.HostConfig{
|
|
OomScoreAdj: 1001,
|
|
OomScoreAdj: 1001,
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1568,17 +1572,17 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *tes
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
name := "oomscoreadj-over"
|
|
name := "oomscoreadj-over"
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, name)
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, name)
|
|
|
|
|
|
expected := "Invalid value 1001, range for oom score adj is [-1000, 1000]"
|
|
expected := "Invalid value 1001, range for oom score adj is [-1000, 1000]"
|
|
assert.ErrorContains(c, err, expected)
|
|
assert.ErrorContains(c, err, expected)
|
|
|
|
|
|
- hostConfig = containertypes.HostConfig{
|
|
|
|
|
|
+ hostConfig = container.HostConfig{
|
|
OomScoreAdj: -1001,
|
|
OomScoreAdj: -1001,
|
|
}
|
|
}
|
|
|
|
|
|
name = "oomscoreadj-low"
|
|
name = "oomscoreadj-low"
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, name)
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, name)
|
|
|
|
|
|
expected = "Invalid value -1001, range for oom score adj is [-1000, 1000]"
|
|
expected = "Invalid value -1001, range for oom score adj is [-1000, 1000]"
|
|
assert.ErrorContains(c, err, expected)
|
|
assert.ErrorContains(c, err, expected)
|
|
@@ -1600,7 +1604,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
|
|
|
|
|
|
name := "testing-network-disabled"
|
|
name := "testing-network-disabled"
|
|
|
|
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
Cmd: []string{"top"},
|
|
Cmd: []string{"top"},
|
|
NetworkDisabled: true,
|
|
NetworkDisabled: true,
|
|
@@ -1610,7 +1614,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, nil, name)
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, name)
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{})
|
|
err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{})
|
|
@@ -1645,8 +1649,8 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
|
|
|
|
|
|
func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
type testCase struct {
|
|
type testCase struct {
|
|
- config containertypes.Config
|
|
|
|
- hostConfig containertypes.HostConfig
|
|
|
|
|
|
+ config container.Config
|
|
|
|
+ hostConfig container.HostConfig
|
|
msg string
|
|
msg string
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1656,11 +1660,11 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
|
|
|
|
cases := []testCase{
|
|
cases := []testCase{
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "notreal",
|
|
Type: "notreal",
|
|
Target: destPath,
|
|
Target: destPath,
|
|
},
|
|
},
|
|
@@ -1670,30 +1674,30 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
msg: "mount type unknown",
|
|
msg: "mount type unknown",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "bind"}}},
|
|
Type: "bind"}}},
|
|
msg: "Target must not be empty",
|
|
msg: "Target must not be empty",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "bind",
|
|
Type: "bind",
|
|
Target: destPath}}},
|
|
Target: destPath}}},
|
|
msg: "Source must not be empty",
|
|
msg: "Source must not be empty",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "bind",
|
|
Type: "bind",
|
|
Source: notExistPath,
|
|
Source: notExistPath,
|
|
Target: destPath}}},
|
|
Target: destPath}}},
|
|
@@ -1702,36 +1706,36 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
// msg: "source path does not exist: " + notExistPath,
|
|
// msg: "source path does not exist: " + notExistPath,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "volume"}}},
|
|
Type: "volume"}}},
|
|
msg: "Target must not be empty",
|
|
msg: "Target must not be empty",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "volume",
|
|
Type: "volume",
|
|
Source: "hello",
|
|
Source: "hello",
|
|
Target: destPath}}},
|
|
Target: destPath}}},
|
|
msg: "",
|
|
msg: "",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "volume",
|
|
Type: "volume",
|
|
Source: "hello2",
|
|
Source: "hello2",
|
|
Target: destPath,
|
|
Target: destPath,
|
|
- VolumeOptions: &mounttypes.VolumeOptions{
|
|
|
|
- DriverConfig: &mounttypes.Driver{
|
|
|
|
|
|
+ VolumeOptions: &mount.VolumeOptions{
|
|
|
|
+ DriverConfig: &mount.Driver{
|
|
Name: "local"}}}}},
|
|
Name: "local"}}}}},
|
|
msg: "",
|
|
msg: "",
|
|
},
|
|
},
|
|
@@ -1743,26 +1747,26 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
defer os.RemoveAll(tmpDir)
|
|
defer os.RemoveAll(tmpDir)
|
|
cases = append(cases, []testCase{
|
|
cases = append(cases, []testCase{
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "bind",
|
|
Type: "bind",
|
|
Source: tmpDir,
|
|
Source: tmpDir,
|
|
Target: destPath}}},
|
|
Target: destPath}}},
|
|
msg: "",
|
|
msg: "",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "bind",
|
|
Type: "bind",
|
|
Source: tmpDir,
|
|
Source: tmpDir,
|
|
Target: destPath,
|
|
Target: destPath,
|
|
- VolumeOptions: &mounttypes.VolumeOptions{}}}},
|
|
|
|
|
|
+ VolumeOptions: &mount.VolumeOptions{}}}},
|
|
msg: "VolumeOptions must not be specified",
|
|
msg: "VolumeOptions must not be specified",
|
|
},
|
|
},
|
|
}...)
|
|
}...)
|
|
@@ -1771,17 +1775,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
if DaemonIsWindows() {
|
|
if DaemonIsWindows() {
|
|
cases = append(cases, []testCase{
|
|
cases = append(cases, []testCase{
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{
|
|
{
|
|
{
|
|
Type: "volume",
|
|
Type: "volume",
|
|
Source: "not-supported-on-windows",
|
|
Source: "not-supported-on-windows",
|
|
Target: destPath,
|
|
Target: destPath,
|
|
- VolumeOptions: &mounttypes.VolumeOptions{
|
|
|
|
- DriverConfig: &mounttypes.Driver{
|
|
|
|
|
|
+ VolumeOptions: &mount.VolumeOptions{
|
|
|
|
+ DriverConfig: &mount.Driver{
|
|
Name: "local",
|
|
Name: "local",
|
|
Options: map[string]string{"type": "tmpfs"},
|
|
Options: map[string]string{"type": "tmpfs"},
|
|
},
|
|
},
|
|
@@ -1797,17 +1801,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
if DaemonIsLinux() {
|
|
if DaemonIsLinux() {
|
|
cases = append(cases, []testCase{
|
|
cases = append(cases, []testCase{
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{
|
|
{
|
|
{
|
|
Type: "volume",
|
|
Type: "volume",
|
|
Source: "missing-device-opt",
|
|
Source: "missing-device-opt",
|
|
Target: destPath,
|
|
Target: destPath,
|
|
- VolumeOptions: &mounttypes.VolumeOptions{
|
|
|
|
- DriverConfig: &mounttypes.Driver{
|
|
|
|
|
|
+ VolumeOptions: &mount.VolumeOptions{
|
|
|
|
+ DriverConfig: &mount.Driver{
|
|
Name: "local",
|
|
Name: "local",
|
|
Options: map[string]string{"foobar": "foobaz"},
|
|
Options: map[string]string{"foobar": "foobaz"},
|
|
},
|
|
},
|
|
@@ -1818,17 +1822,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
msg: `invalid option: "foobar"`,
|
|
msg: `invalid option: "foobar"`,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{
|
|
{
|
|
{
|
|
Type: "volume",
|
|
Type: "volume",
|
|
Source: "missing-device-opt",
|
|
Source: "missing-device-opt",
|
|
Target: destPath,
|
|
Target: destPath,
|
|
- VolumeOptions: &mounttypes.VolumeOptions{
|
|
|
|
- DriverConfig: &mounttypes.Driver{
|
|
|
|
|
|
+ VolumeOptions: &mount.VolumeOptions{
|
|
|
|
+ DriverConfig: &mount.Driver{
|
|
Name: "local",
|
|
Name: "local",
|
|
Options: map[string]string{"type": "tmpfs"},
|
|
Options: map[string]string{"type": "tmpfs"},
|
|
},
|
|
},
|
|
@@ -1839,17 +1843,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
msg: `missing required option: "device"`,
|
|
msg: `missing required option: "device"`,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{
|
|
{
|
|
{
|
|
Type: "volume",
|
|
Type: "volume",
|
|
Source: "missing-type-opt",
|
|
Source: "missing-type-opt",
|
|
Target: destPath,
|
|
Target: destPath,
|
|
- VolumeOptions: &mounttypes.VolumeOptions{
|
|
|
|
- DriverConfig: &mounttypes.Driver{
|
|
|
|
|
|
+ VolumeOptions: &mount.VolumeOptions{
|
|
|
|
+ DriverConfig: &mount.Driver{
|
|
Name: "local",
|
|
Name: "local",
|
|
Options: map[string]string{"device": "tmpfs"},
|
|
Options: map[string]string{"device": "tmpfs"},
|
|
},
|
|
},
|
|
@@ -1860,17 +1864,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
msg: `missing required option: "type"`,
|
|
msg: `missing required option: "type"`,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{
|
|
{
|
|
{
|
|
Type: "volume",
|
|
Type: "volume",
|
|
Source: "hello4",
|
|
Source: "hello4",
|
|
Target: destPath,
|
|
Target: destPath,
|
|
- VolumeOptions: &mounttypes.VolumeOptions{
|
|
|
|
- DriverConfig: &mounttypes.Driver{
|
|
|
|
|
|
+ VolumeOptions: &mount.VolumeOptions{
|
|
|
|
+ DriverConfig: &mount.Driver{
|
|
Name: "local",
|
|
Name: "local",
|
|
Options: map[string]string{"o": "size=1", "type": "tmpfs", "device": "tmpfs"},
|
|
Options: map[string]string{"o": "size=1", "type": "tmpfs", "device": "tmpfs"},
|
|
},
|
|
},
|
|
@@ -1881,35 +1885,35 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
msg: "",
|
|
msg: "",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "tmpfs",
|
|
Type: "tmpfs",
|
|
Target: destPath}}},
|
|
Target: destPath}}},
|
|
msg: "",
|
|
msg: "",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "tmpfs",
|
|
Type: "tmpfs",
|
|
Target: destPath,
|
|
Target: destPath,
|
|
- TmpfsOptions: &mounttypes.TmpfsOptions{
|
|
|
|
|
|
+ TmpfsOptions: &mount.TmpfsOptions{
|
|
SizeBytes: 4096 * 1024,
|
|
SizeBytes: 4096 * 1024,
|
|
Mode: 0700,
|
|
Mode: 0700,
|
|
}}}},
|
|
}}}},
|
|
msg: "",
|
|
msg: "",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- config: containertypes.Config{
|
|
|
|
|
|
+ config: container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
},
|
|
},
|
|
- hostConfig: containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{{
|
|
|
|
|
|
+ hostConfig: container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{{
|
|
Type: "tmpfs",
|
|
Type: "tmpfs",
|
|
Source: "/shouldnotbespecified",
|
|
Source: "/shouldnotbespecified",
|
|
Target: destPath}}},
|
|
Target: destPath}}},
|
|
@@ -1926,7 +1930,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
|
for i, x := range cases {
|
|
for i, x := range cases {
|
|
x := x
|
|
x := x
|
|
c.Run(fmt.Sprintf("case %d", i), func(c *testing.T) {
|
|
c.Run(fmt.Sprintf("case %d", i), func(c *testing.T) {
|
|
- _, err = apiClient.ContainerCreate(context.Background(), &x.config, &x.hostConfig, &networktypes.NetworkingConfig{}, nil, "")
|
|
|
|
|
|
+ _, err = apiClient.ContainerCreate(context.Background(), &x.config, &x.hostConfig, &network.NetworkingConfig{}, nil, "")
|
|
if len(x.msg) > 0 {
|
|
if len(x.msg) > 0 {
|
|
assert.ErrorContains(c, err, x.msg, "%v", cases[i].config)
|
|
assert.ErrorContains(c, err, x.msg, "%v", cases[i].config)
|
|
} else {
|
|
} else {
|
|
@@ -1946,12 +1950,12 @@ func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
|
|
defer os.RemoveAll(tmpDir)
|
|
defer os.RemoveAll(tmpDir)
|
|
err = os.WriteFile(filepath.Join(tmpDir, "bar"), []byte("hello"), 0666)
|
|
err = os.WriteFile(filepath.Join(tmpDir, "bar"), []byte("hello"), 0666)
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
Cmd: []string{"/bin/sh", "-c", "cat /foo/bar"},
|
|
Cmd: []string{"/bin/sh", "-c", "cat /foo/bar"},
|
|
}
|
|
}
|
|
- hostConfig := containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{
|
|
|
|
|
|
+ hostConfig := container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{
|
|
{Type: "bind", Source: tmpDir, Target: destPath},
|
|
{Type: "bind", Source: tmpDir, Target: destPath},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
@@ -1959,7 +1963,7 @@ func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, "test")
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, "test")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
|
|
|
|
out, _ := dockerCmd(c, "start", "-a", "test")
|
|
out, _ := dockerCmd(c, "start", "-a", "test")
|
|
@@ -1986,7 +1990,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
type testCase struct {
|
|
type testCase struct {
|
|
- spec mounttypes.Mount
|
|
|
|
|
|
+ spec mount.Mount
|
|
expected types.MountPoint
|
|
expected types.MountPoint
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2004,23 +2008,23 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
|
// use literal strings here for `Type` instead of the defined constants in the volume package to keep this honest
|
|
// use literal strings here for `Type` instead of the defined constants in the volume package to keep this honest
|
|
// Validation of the actual `Mount` struct is done in another test is not needed here
|
|
// Validation of the actual `Mount` struct is done in another test is not needed here
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "volume", Target: destPath},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "volume", Target: destPath},
|
|
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "volume", Target: destPath + slash},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "volume", Target: destPath + slash},
|
|
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test1"},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "volume", Target: destPath, Source: "test1"},
|
|
expected: types.MountPoint{Type: "volume", Name: "test1", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
expected: types.MountPoint{Type: "volume", Name: "test1", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "volume", Target: destPath, ReadOnly: true, Source: "test2"},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "volume", Target: destPath, ReadOnly: true, Source: "test2"},
|
|
expected: types.MountPoint{Type: "volume", Name: "test2", RW: false, Destination: destPath, Mode: selinuxSharedLabel},
|
|
expected: types.MountPoint{Type: "volume", Name: "test2", RW: false, Destination: destPath, Mode: selinuxSharedLabel},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test3", VolumeOptions: &mounttypes.VolumeOptions{DriverConfig: &mounttypes.Driver{Name: volume.DefaultDriverName}}},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "volume", Target: destPath, Source: "test3", VolumeOptions: &mount.VolumeOptions{DriverConfig: &mount.Driver{Name: volume.DefaultDriverName}}},
|
|
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", Name: "test3", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", Name: "test3", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
@@ -2032,7 +2036,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
|
defer os.RemoveAll(tmpDir1)
|
|
defer os.RemoveAll(tmpDir1)
|
|
cases = append(cases, []testCase{
|
|
cases = append(cases, []testCase{
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{
|
|
|
|
|
|
+ spec: mount.Mount{
|
|
Type: "bind",
|
|
Type: "bind",
|
|
Source: tmpDir1,
|
|
Source: tmpDir1,
|
|
Target: destPath,
|
|
Target: destPath,
|
|
@@ -2045,7 +2049,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "bind", Source: tmpDir1, Target: destPath, ReadOnly: true},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "bind", Source: tmpDir1, Target: destPath, ReadOnly: true},
|
|
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir1},
|
|
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir1},
|
|
},
|
|
},
|
|
}...)
|
|
}...)
|
|
@@ -2060,15 +2064,15 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
|
|
|
|
|
cases = append(cases, []testCase{
|
|
cases = append(cases, []testCase{
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath},
|
|
expected: types.MountPoint{Type: "bind", RW: true, Destination: destPath, Source: tmpDir3},
|
|
expected: types.MountPoint{Type: "bind", RW: true, Destination: destPath, Source: tmpDir3},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true},
|
|
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3},
|
|
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true, BindOptions: &mounttypes.BindOptions{Propagation: "shared"}},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true, BindOptions: &mount.BindOptions{Propagation: "shared"}},
|
|
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3, Propagation: "shared"},
|
|
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3, Propagation: "shared"},
|
|
},
|
|
},
|
|
}...)
|
|
}...)
|
|
@@ -2078,19 +2082,19 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
|
if testEnv.OSType != "windows" { // Windows does not support volume populate
|
|
if testEnv.OSType != "windows" { // Windows does not support volume populate
|
|
cases = append(cases, []testCase{
|
|
cases = append(cases, []testCase{
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "volume", Target: destPath, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "volume", Target: destPath, VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
|
|
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "volume", Target: destPath + slash, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "volume", Target: destPath + slash, VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
|
|
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test4", VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "volume", Target: destPath, Source: "test4", VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
|
|
expected: types.MountPoint{Type: "volume", Name: "test4", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
expected: types.MountPoint{Type: "volume", Name: "test4", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- spec: mounttypes.Mount{Type: "volume", Target: destPath, Source: "test5", ReadOnly: true, VolumeOptions: &mounttypes.VolumeOptions{NoCopy: true}},
|
|
|
|
|
|
+ spec: mount.Mount{Type: "volume", Target: destPath, Source: "test5", ReadOnly: true, VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
|
|
expected: types.MountPoint{Type: "volume", Name: "test5", RW: false, Destination: destPath, Mode: selinuxSharedLabel},
|
|
expected: types.MountPoint{Type: "volume", Name: "test5", RW: false, Destination: destPath, Mode: selinuxSharedLabel},
|
|
},
|
|
},
|
|
}...)
|
|
}...)
|
|
@@ -2103,9 +2107,9 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
|
c.Run(fmt.Sprintf("%d config: %v", i, x.spec), func(c *testing.T) {
|
|
c.Run(fmt.Sprintf("%d config: %v", i, x.spec), func(c *testing.T) {
|
|
container, err := apiclient.ContainerCreate(
|
|
container, err := apiclient.ContainerCreate(
|
|
ctx,
|
|
ctx,
|
|
- &containertypes.Config{Image: testImg},
|
|
|
|
- &containertypes.HostConfig{Mounts: []mounttypes.Mount{x.spec}},
|
|
|
|
- &networktypes.NetworkingConfig{},
|
|
|
|
|
|
+ &container.Config{Image: testImg},
|
|
|
|
+ &container.HostConfig{Mounts: []mount.Mount{x.spec}},
|
|
|
|
+ &network.NetworkingConfig{},
|
|
nil,
|
|
nil,
|
|
"")
|
|
"")
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
@@ -2179,22 +2183,22 @@ func containerExit(apiclient client.APIClient, name string) func(poll.LogT) poll
|
|
func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
|
|
func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
type testCase struct {
|
|
type testCase struct {
|
|
- cfg mounttypes.Mount
|
|
|
|
|
|
+ cfg mount.Mount
|
|
expectedOptions []string
|
|
expectedOptions []string
|
|
}
|
|
}
|
|
target := "/foo"
|
|
target := "/foo"
|
|
cases := []testCase{
|
|
cases := []testCase{
|
|
{
|
|
{
|
|
- cfg: mounttypes.Mount{
|
|
|
|
|
|
+ cfg: mount.Mount{
|
|
Type: "tmpfs",
|
|
Type: "tmpfs",
|
|
Target: target},
|
|
Target: target},
|
|
expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime"},
|
|
expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime"},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- cfg: mounttypes.Mount{
|
|
|
|
|
|
+ cfg: mount.Mount{
|
|
Type: "tmpfs",
|
|
Type: "tmpfs",
|
|
Target: target,
|
|
Target: target,
|
|
- TmpfsOptions: &mounttypes.TmpfsOptions{
|
|
|
|
|
|
+ TmpfsOptions: &mount.TmpfsOptions{
|
|
SizeBytes: 4096 * 1024, Mode: 0700}},
|
|
SizeBytes: 4096 * 1024, Mode: 0700}},
|
|
expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime", "size=4096k", "mode=700"},
|
|
expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime", "size=4096k", "mode=700"},
|
|
},
|
|
},
|
|
@@ -2204,17 +2208,17 @@ func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
defer cli.Close()
|
|
defer cli.Close()
|
|
|
|
|
|
- config := containertypes.Config{
|
|
|
|
|
|
+ config := container.Config{
|
|
Image: "busybox",
|
|
Image: "busybox",
|
|
Cmd: []string{"/bin/sh", "-c", fmt.Sprintf("mount | grep 'tmpfs on %s'", target)},
|
|
Cmd: []string{"/bin/sh", "-c", fmt.Sprintf("mount | grep 'tmpfs on %s'", target)},
|
|
}
|
|
}
|
|
for i, x := range cases {
|
|
for i, x := range cases {
|
|
cName := fmt.Sprintf("test-tmpfs-%d", i)
|
|
cName := fmt.Sprintf("test-tmpfs-%d", i)
|
|
- hostConfig := containertypes.HostConfig{
|
|
|
|
- Mounts: []mounttypes.Mount{x.cfg},
|
|
|
|
|
|
+ hostConfig := container.HostConfig{
|
|
|
|
+ Mounts: []mount.Mount{x.cfg},
|
|
}
|
|
}
|
|
|
|
|
|
- _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &networktypes.NetworkingConfig{}, nil, cName)
|
|
|
|
|
|
+ _, err = cli.ContainerCreate(context.Background(), &config, &hostConfig, &network.NetworkingConfig{}, nil, cName)
|
|
assert.NilError(c, err)
|
|
assert.NilError(c, err)
|
|
out, _ := dockerCmd(c, "start", "-a", cName)
|
|
out, _ := dockerCmd(c, "start", "-a", cName)
|
|
for _, option := range x.expectedOptions {
|
|
for _, option := range x.expectedOptions {
|