Skip to content

fix: correctly parse image digest #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions cli/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,14 @@ func runDockerCVM(ctx context.Context, log slog.Logger, client dockerutil.Client
if err != nil {
return xerrors.Errorf("set oom score: %w", err)
}
ref, err := name.NewTag(flags.innerImage)
ref, err := name.ParseReference(flags.innerImage)
if err != nil {
return xerrors.Errorf("parse ref: %w", err)
}

var dockerAuth dockerutil.AuthConfig
if flags.imagePullSecret != "" {
dockerAuth, err = dockerutil.AuthConfigFromString(flags.imagePullSecret, ref.RegistryStr())
dockerAuth, err = dockerutil.AuthConfigFromString(flags.imagePullSecret, ref.Context().RegistryStr())
if err != nil {
return xerrors.Errorf("parse auth config: %w", err)
}
Expand All @@ -415,7 +415,7 @@ func runDockerCVM(ctx context.Context, log slog.Logger, client dockerutil.Client
log.Info(ctx, "checking for docker config file", slog.F("path", flags.dockerConfig))
if _, err := fs.Stat(flags.dockerConfig); err == nil {
log.Info(ctx, "detected file", slog.F("image", flags.innerImage))
dockerAuth, err = dockerutil.AuthConfigFromPath(flags.dockerConfig, ref.RegistryStr())
dockerAuth, err = dockerutil.AuthConfigFromPath(flags.dockerConfig, ref.Context().RegistryStr())
if err != nil && !xerrors.Is(err, os.ErrNotExist) {
return xerrors.Errorf("auth config from file: %w", err)
}
Expand Down Expand Up @@ -656,6 +656,13 @@ func runDockerCVM(ctx context.Context, log slog.Logger, client dockerutil.Client
}

blog.Info("Creating workspace...")
// If imgMeta.HasInit is true, we just use flags.boostrapScript as the entrypoint.
// But if it's false, we need to run /sbin/init as the entrypoint.
// We need to mount or run some exec command that injects a systemd service for starting
// the coder agent.

// We need to check that if PID1 is systemd (or /sbin/init) that systemd propagates SIGTERM
// to service units. If it doesn't then this solution doesn't help us.

// Create the inner container.
containerID, err := dockerutil.CreateContainer(ctx, client, &dockerutil.ContainerConfig{
Expand Down
5 changes: 5 additions & 0 deletions cli/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ func TestDocker(t *testing.T) {
image: "gcr.io/ubuntu:24.04",
success: true,
},
{
name: "RegistryRepositorySha",
image: "gcr.io/images/helloworld@sha256:13e101dd511a26a2147e123456bdff5845c9461aaa53d856845745b063001234",
success: true,
},
}

for _, tc := range testcases {
Expand Down
Loading