Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit 97a5347

Browse files
committed
Clean up a few bits post-rebase and don't return on nil error.
Signed-off-by: Jacob Howard <jacob.howard@docker.com>
1 parent 5900e78 commit 97a5347

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

pkg/standalone/containers.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,24 +265,31 @@ func CreateControllerContainer(ctx context.Context, dockerClient *client.Client,
265265
}
266266

267267
// Create the container. If we detect that a concurrent installation is in
268-
// progress, then we wait for whichever install process creates the
269-
// container first and then wait for its container to be ready.
268+
// progress (as indicated by a conflicting container name (which should have
269+
// been detected just before installation)), then we'll allow the error to
270+
// pass silently and simply work in conjunction with any concurrent
271+
// installers to start the container.
270272
resp, err := dockerClient.ContainerCreate(ctx, config, hostConfig, nil, nil, controllerContainerName)
271-
if !errdefs.IsConflict(err) {
273+
if err != nil && !errdefs.IsConflict(err) {
272274
return fmt.Errorf("failed to create container %s: %w", controllerContainerName, err)
273275
}
276+
created := err == nil
274277

275278
// Start the container.
276279
printer.Printf("Starting model runner container %s...\n", controllerContainerName)
277280
if err := waitForContainerToStart(ctx, dockerClient, controllerContainerName); err != nil {
278-
_ = dockerClient.ContainerRemove(ctx, resp.ID, container.RemoveOptions{Force: true})
281+
if created {
282+
_ = dockerClient.ContainerRemove(ctx, resp.ID, container.RemoveOptions{Force: true})
283+
}
279284
return fmt.Errorf("failed to start container %s: %w", controllerContainerName, err)
280285
}
281286

282-
// Copy Docker config file if it exists
283-
if err := copyDockerConfigToContainer(ctx, dockerClient, resp.ID, engineKind); err != nil {
284-
// Log warning but continue - don't fail container creation
285-
printer.Printf("Warning: failed to copy Docker config: %v\n", err)
287+
// Copy Docker config file if it exists and we're the container creator.
288+
if created {
289+
if err := copyDockerConfigToContainer(ctx, dockerClient, resp.ID, engineKind); err != nil {
290+
// Log warning but continue - don't fail container creation
291+
printer.Printf("Warning: failed to copy Docker config: %v\n", err)
292+
}
286293
}
287294
return nil
288295
}

0 commit comments

Comments
 (0)