mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client/container_create: Rename ContainerName to Name
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -34,8 +34,8 @@ func (cli *Client) ContainerCreate(ctx context.Context, options ContainerCreateO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.ContainerName != "" {
|
if options.Name != "" {
|
||||||
query.Set("name", options.ContainerName)
|
query.Set("name", options.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
body := container.CreateRequest{
|
body := container.CreateRequest{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type ContainerCreateOptions struct {
|
|||||||
HostConfig *container.HostConfig
|
HostConfig *container.HostConfig
|
||||||
NetworkingConfig *network.NetworkingConfig
|
NetworkingConfig *network.NetworkingConfig
|
||||||
Platform *ocispec.Platform
|
Platform *ocispec.Platform
|
||||||
ContainerName string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerCreateResult is the result from creating a container.
|
// ContainerCreateResult is the result from creating a container.
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ func TestContainerCreateError(t *testing.T) {
|
|||||||
)
|
)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
_, err = client.ContainerCreate(context.Background(), ContainerCreateOptions{Config: nil, ContainerName: "nothing"})
|
_, err = client.ContainerCreate(context.Background(), ContainerCreateOptions{Config: nil, Name: "nothing"})
|
||||||
assert.Error(t, err, "config is nil")
|
assert.Error(t, err, "config is nil")
|
||||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||||
|
|
||||||
_, err = client.ContainerCreate(context.Background(), ContainerCreateOptions{Config: &container.Config{}, ContainerName: "nothing"})
|
_, err = client.ContainerCreate(context.Background(), ContainerCreateOptions{Config: &container.Config{}, Name: "nothing"})
|
||||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||||
|
|
||||||
// 404 doesn't automatically means an unknown image
|
// 404 doesn't automatically means an unknown image
|
||||||
@@ -35,7 +35,7 @@ func TestContainerCreateError(t *testing.T) {
|
|||||||
)
|
)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
_, err = client.ContainerCreate(context.Background(), ContainerCreateOptions{Config: &container.Config{}, ContainerName: "nothing"})
|
_, err = client.ContainerCreate(context.Background(), ContainerCreateOptions{Config: &container.Config{}, Name: "nothing"})
|
||||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
|
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ func TestContainerCreateImageNotFound(t *testing.T) {
|
|||||||
)
|
)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
_, err = client.ContainerCreate(context.Background(), ContainerCreateOptions{Config: &container.Config{Image: "unknown_image"}, ContainerName: "unknown"})
|
_, err = client.ContainerCreate(context.Background(), ContainerCreateOptions{Config: &container.Config{Image: "unknown_image"}, Name: "unknown"})
|
||||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
|
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ func TestContainerCreateWithName(t *testing.T) {
|
|||||||
)
|
)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
r, err := client.ContainerCreate(context.Background(), ContainerCreateOptions{Config: &container.Config{}, ContainerName: "container_name"})
|
r, err := client.ContainerCreate(context.Background(), ContainerCreateOptions{Config: &container.Config{}, Name: "container_name"})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Check(t, is.Equal(r.ID, "container_id"))
|
assert.Check(t, is.Equal(r.ID, "container_id"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -770,7 +770,7 @@ func (s *DockerAPISuite) TestContainerAPIStart(c *testing.T) {
|
|||||||
Config: &config,
|
Config: &config,
|
||||||
HostConfig: &container.HostConfig{},
|
HostConfig: &container.HostConfig{},
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: name,
|
Name: name,
|
||||||
})
|
})
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
@@ -1018,7 +1018,7 @@ func (s *DockerAPISuite) TestPostContainersCreateWithWrongCpusetValues(c *testin
|
|||||||
Config: &config,
|
Config: &config,
|
||||||
HostConfig: &hostConfig1,
|
HostConfig: &hostConfig1,
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: name,
|
Name: 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)
|
||||||
@@ -1033,7 +1033,7 @@ func (s *DockerAPISuite) TestPostContainersCreateWithWrongCpusetValues(c *testin
|
|||||||
Config: &config,
|
Config: &config,
|
||||||
HostConfig: &hostConfig2,
|
HostConfig: &hostConfig2,
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: name2,
|
Name: name2,
|
||||||
})
|
})
|
||||||
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)
|
||||||
@@ -1085,7 +1085,7 @@ func (s *DockerAPISuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *
|
|||||||
Config: &config,
|
Config: &config,
|
||||||
HostConfig: &hostConfig,
|
HostConfig: &hostConfig,
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: name,
|
Name: 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]"
|
||||||
@@ -1100,7 +1100,7 @@ func (s *DockerAPISuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *
|
|||||||
Config: &config,
|
Config: &config,
|
||||||
HostConfig: &hostConfig,
|
HostConfig: &hostConfig,
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: name2,
|
Name: name2,
|
||||||
})
|
})
|
||||||
|
|
||||||
expected = "Invalid value -1001, range for oom score adj is [-1000, 1000]"
|
expected = "Invalid value -1001, range for oom score adj is [-1000, 1000]"
|
||||||
@@ -1138,7 +1138,7 @@ func (s *DockerAPISuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T)
|
|||||||
Config: &config,
|
Config: &config,
|
||||||
HostConfig: &container.HostConfig{},
|
HostConfig: &container.HostConfig{},
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: name,
|
Name: name,
|
||||||
})
|
})
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
@@ -1516,7 +1516,7 @@ func (s *DockerAPISuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
|
|||||||
Config: &config,
|
Config: &config,
|
||||||
HostConfig: &hostConfig,
|
HostConfig: &hostConfig,
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: "test",
|
Name: "test",
|
||||||
})
|
})
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
@@ -1772,7 +1772,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
|
|||||||
Config: &config,
|
Config: &config,
|
||||||
HostConfig: &hostConfig,
|
HostConfig: &hostConfig,
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: cName,
|
Name: cName,
|
||||||
})
|
})
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
out := cli.DockerCmd(c, "start", "-a", cName).Combined()
|
out := cli.DockerCmd(c, "start", "-a", cName).Combined()
|
||||||
|
|||||||
@@ -65,10 +65,10 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsBindNamedPipe(c *testing.T
|
|||||||
Target: containerPipeName,
|
Target: containerPipeName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: name,
|
Name: name,
|
||||||
})
|
})
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
err = apiClient.ContainerStart(ctx, name, client.ContainerStartOptions{})
|
err = apiClient.ContainerStart(ctx, name, client.ContainerStartOptions{})
|
||||||
|
|||||||
@@ -600,7 +600,7 @@ func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c
|
|||||||
Config: &config,
|
Config: &config,
|
||||||
HostConfig: &hostConfig,
|
HostConfig: &hostConfig,
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: "app",
|
Name: "app",
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ func TestCreateWithCustomMaskedPaths(t *testing.T) {
|
|||||||
Privileged: tc.privileged,
|
Privileged: tc.privileged,
|
||||||
MaskedPaths: tc.maskedPaths,
|
MaskedPaths: tc.maskedPaths,
|
||||||
},
|
},
|
||||||
ContainerName: fmt.Sprintf("create-masked-paths-%d", i),
|
Name: fmt.Sprintf("create-masked-paths-%d", i),
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ func TestCreateWithCustomReadonlyPaths(t *testing.T) {
|
|||||||
Privileged: tc.privileged,
|
Privileged: tc.privileged,
|
||||||
ReadonlyPaths: tc.readonlyPaths,
|
ReadonlyPaths: tc.readonlyPaths,
|
||||||
},
|
},
|
||||||
ContainerName: fmt.Sprintf("create-readonly-paths-%d", i),
|
Name: fmt.Sprintf("create-readonly-paths-%d", i),
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ func TestContainerVolumeAnonymous(t *testing.T) {
|
|||||||
HostConfig: config.HostConfig,
|
HostConfig: config.HostConfig,
|
||||||
NetworkingConfig: config.NetworkingConfig,
|
NetworkingConfig: config.NetworkingConfig,
|
||||||
Platform: config.Platform,
|
Platform: config.Platform,
|
||||||
ContainerName: config.Name,
|
Name: config.Name,
|
||||||
})
|
})
|
||||||
// We use [testNonExistingPlugin] for this, which produces an error
|
// We use [testNonExistingPlugin] for this, which produces an error
|
||||||
// when used, which we use as indicator that the driver was passed
|
// when used, which we use as indicator that the driver was passed
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func TestGraphDriverPersistence(t *testing.T) {
|
|||||||
Image: testImage,
|
Image: testImage,
|
||||||
Cmd: []string{"echo", "test"},
|
Cmd: []string{"echo", "test"},
|
||||||
},
|
},
|
||||||
ContainerName: "test-container",
|
Name: "test-container",
|
||||||
})
|
})
|
||||||
assert.NilError(t, err, "Failed to create container")
|
assert.NilError(t, err, "Failed to create container")
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func Create(ctx context.Context, t *testing.T, apiClient client.APIClient, ops .
|
|||||||
HostConfig: config.HostConfig,
|
HostConfig: config.HostConfig,
|
||||||
NetworkingConfig: config.NetworkingConfig,
|
NetworkingConfig: config.NetworkingConfig,
|
||||||
Platform: config.Platform,
|
Platform: config.Platform,
|
||||||
ContainerName: config.Name,
|
Name: config.Name,
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ func CreateFromConfig(ctx context.Context, apiClient client.APIClient, config *T
|
|||||||
HostConfig: config.HostConfig,
|
HostConfig: config.HostConfig,
|
||||||
NetworkingConfig: config.NetworkingConfig,
|
NetworkingConfig: config.NetworkingConfig,
|
||||||
Platform: config.Platform,
|
Platform: config.Platform,
|
||||||
ContainerName: config.Name,
|
Name: config.Name,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -968,7 +968,7 @@ func TestEmptyPortBindingsBC(t *testing.T) {
|
|||||||
HostConfig: config.HostConfig,
|
HostConfig: config.HostConfig,
|
||||||
NetworkingConfig: config.NetworkingConfig,
|
NetworkingConfig: config.NetworkingConfig,
|
||||||
Platform: config.Platform,
|
Platform: config.Platform,
|
||||||
ContainerName: config.Name,
|
Name: config.Name,
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
defer apiClient.ContainerRemove(ctx, c.ID, client.ContainerRemoveOptions{Force: true})
|
defer apiClient.ContainerRemove(ctx, c.ID, client.ContainerRemoveOptions{Force: true})
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ func TestRunMountVolumeSubdir(t *testing.T) {
|
|||||||
Config: &cfg,
|
Config: &cfg,
|
||||||
HostConfig: &hostCfg,
|
HostConfig: &hostCfg,
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: ctrName,
|
Name: ctrName,
|
||||||
})
|
})
|
||||||
id := create.ID
|
id := create.ID
|
||||||
if id != "" {
|
if id != "" {
|
||||||
@@ -184,7 +184,7 @@ func TestRunMountImage(t *testing.T) {
|
|||||||
Config: &cfg,
|
Config: &cfg,
|
||||||
HostConfig: &hostCfg,
|
HostConfig: &hostCfg,
|
||||||
NetworkingConfig: &network.NetworkingConfig{},
|
NetworkingConfig: &network.NetworkingConfig{},
|
||||||
ContainerName: ctrName,
|
Name: ctrName,
|
||||||
})
|
})
|
||||||
id := create.ID
|
id := create.ID
|
||||||
if id != "" {
|
if id != "" {
|
||||||
|
|||||||
@@ -155,9 +155,9 @@ COPY . /static`); err != nil {
|
|||||||
|
|
||||||
// Start the container
|
// Start the container
|
||||||
b, err := c.ContainerCreate(context.Background(), client.ContainerCreateOptions{
|
b, err := c.ContainerCreate(context.Background(), client.ContainerCreateOptions{
|
||||||
Config: &containertypes.Config{Image: imgName},
|
Config: &containertypes.Config{Image: imgName},
|
||||||
HostConfig: &containertypes.HostConfig{PublishAllPorts: true},
|
HostConfig: &containertypes.HostConfig{PublishAllPorts: true},
|
||||||
ContainerName: ctrName,
|
Name: ctrName,
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
err = c.ContainerStart(context.Background(), b.ID, client.ContainerStartOptions{})
|
err = c.ContainerStart(context.Background(), b.ID, client.ContainerStartOptions{})
|
||||||
|
|||||||
4
vendor/github.com/moby/moby/client/container_create.go
generated
vendored
4
vendor/github.com/moby/moby/client/container_create.go
generated
vendored
@@ -34,8 +34,8 @@ func (cli *Client) ContainerCreate(ctx context.Context, options ContainerCreateO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.ContainerName != "" {
|
if options.Name != "" {
|
||||||
query.Set("name", options.ContainerName)
|
query.Set("name", options.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
body := container.CreateRequest{
|
body := container.CreateRequest{
|
||||||
|
|||||||
2
vendor/github.com/moby/moby/client/container_create_opts.go
generated
vendored
2
vendor/github.com/moby/moby/client/container_create_opts.go
generated
vendored
@@ -12,7 +12,7 @@ type ContainerCreateOptions struct {
|
|||||||
HostConfig *container.HostConfig
|
HostConfig *container.HostConfig
|
||||||
NetworkingConfig *network.NetworkingConfig
|
NetworkingConfig *network.NetworkingConfig
|
||||||
Platform *ocispec.Platform
|
Platform *ocispec.Platform
|
||||||
ContainerName string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerCreateResult is the result from creating a container.
|
// ContainerCreateResult is the result from creating a container.
|
||||||
|
|||||||
Reference in New Issue
Block a user