Skip to content

Modern Docker Management, Designed for Everyone

feat: container update indicator directly in the table (#1077)

Kyle Mendelleb7f29116fd7
diff --git a/backend/internal/huma/handlers/updater.go b/backend/internal/huma/handlers/updater.go
index e0f878675..e1bea506e 100644
--- a/backend/internal/huma/handlers/updater.go
+++ b/backend/internal/huma/handlers/updater.go
@@ -28,6 +28,15 @@ type RunUpdaterOutput struct {
Body base.ApiResponse[*updater.Result]
}
+type UpdateContainerInput struct {
+ EnvironmentID string `path:"id" doc:"Environment ID"`
+ ContainerID string `path:"containerId" doc:"Container ID to update"`
+}
+
+type UpdateContainerOutput struct {
+ Body base.ApiResponse[*updater.Result]
+}
+
type GetUpdaterStatusInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
}
@@ -89,6 +98,19 @@ func RegisterUpdater(api huma.API, updaterService *services.UpdaterService) {
{"ApiKeyAuth": {}},
},
}, h.GetUpdaterHistory)
+
+ huma.Register(api, huma.Operation{
+ OperationID: "update-container",
+ Method: http.MethodPost,
+ Path: "/environments/{id}/containers/{containerId}/update",
+ Summary: "Update a single container",
+ Description: "Pull the latest image and recreate a specific container",
+ Tags: []string{"Updater", "Containers"},
+ Security: []map[string][]string{
+ {"BearerAuth": {}},
+ {"ApiKeyAuth": {}},
+ },
+ }, h.UpdateContainer)
}
// RunUpdater applies pending container updates.
@@ -154,3 +176,22 @@ func (h *UpdaterHandler) GetUpdaterHistory(ctx context.Context, input *GetUpdate
},
}, nil
}
+
+// UpdateContainer updates a single container by pulling the latest image and recreating it.
+func (h *UpdaterHandler) UpdateContainer(ctx context.Context, input *UpdateContainerInput) (*UpdateContainerOutput, error) {
+ if h.updaterService == nil {
+ return nil, huma.Error500InternalServerError("service not available")
+ }
+
+ out, err := h.updaterService.UpdateSingleContainer(ctx, input.ContainerID)
+ if err != nil {
+ return nil, huma.Error500InternalServerError((&common.UpdaterRunError{Err: err}).Error())
+ }
+
+ return &UpdateContainerOutput{
+ Body: base.ApiResponse[*updater.Result]{
+ Success: true,
+ Data: out,
+ },
+ }, nil
+}
diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.go
index 4c7f173c6..0bcba5374 100644
--- a/backend/internal/services/container_service.go
+++ b/backend/internal/services/container_service.go
@@ -19,6 +19,7 @@ import (
"github.com/getarcaneapp/arcane/backend/internal/utils/pagination"
containertypes "go.getarcane.app/types/container"
"go.getarcane.app/types/containerregistry"
+ imagetypes "go.getarcane.app/types/image"
)
type ContainerService struct {
@@ -418,9 +419,39 @@ func (s *ContainerService) ListContainersPaginated(ctx context.Context, params p
return nil, pagination.Response{}, containertypes.StatusCounts{}, fmt.Errorf("failed to list Docker containers: %w", err)
}
+ // Collect unique image IDs for update info lookup
+ imageIDSet := make(map[string]struct{}, len(dockerContainers))
+ for _, dc := range dockerContainers {
+ if dc.ImageID != "" {
+ imageIDSet[dc.ImageID] = struct{}{}
+ }
+ }
+ imageIDs := make([]string, 0, len(imageIDSet))
+ for id := range imageIDSet {
+ imageIDs = append(imageIDs, id)
+ }
+
+ // Fetch update info for all images used by containers
+ var updateInfoMap map[string]*imagetypes.UpdateInfo
+ if s.imageService != nil && len(imageIDs) > 0 {
+ updateInfoMap, err = s.imageService.GetUpdateInfoByImageIDs(ctx, imageIDs)
+ if err != nil {
+ // Log error but continue - update info is optional
+ slog.WarnContext(ctx, "Failed to fetch image update info for containers", "error", err)
+ updateInfoMap = make(map[string]*imagetypes.UpdateInfo)
+ }
+ } else {
+ updateInfoMap = make(map[string]*imagetypes.UpdateInfo)
+ }
+
items := make([]containertypes.Summary, 0, len(dockerContainers))
for _, dc := range dockerContainers {
- items = append(items, containertypes.NewSummary(dc))
+ summary := containertypes.NewSummary(dc)
+ // Attach update info if available
+ if info, exists := updateInfoMap[dc.ImageID]; exists {
+ summary.UpdateInfo = info
+ }
+ items = append(items, summary)
}
config := pagination.Config[containertypes.Summary]{
diff --git a/backend/internal/services/image_service.go b/backend/internal/services/image_service.go
index 766406483..d19b35790 100644
--- a/backend/internal/services/image_service.go
+++ b/backend/internal/services/image_service.go
@@ -401,6 +401,26 @@ func (s *ImageService) PruneImages(ctx context.Context, dangling bool) (*image.P
return &report, nil
}
+// GetUpdateInfoByImageIDs returns a map of image ID to UpdateInfo for the given image IDs.
+// This is used by the container service to populate update info for containers.
+func (s *ImageService) GetUpdateInfoByImageIDs(ctx context.Context, imageIDs []string) (map[string]*imagetypes.UpdateInfo, error) {
+ if s.db == nil || len(imageIDs) == 0 {
+ return make(map[string]*imagetypes.UpdateInfo), nil
+ }
+
+ var updateRecords []models.ImageUpdateRecord
+ if err := s.db.WithContext(ctx).Where("id IN ?", imageIDs).Find(&updateRecords).Error; err != nil {
+ return nil, fmt.Errorf("failed to fetch update records: %w", err)
+ }
+
+ result := make(map[string]*imagetypes.UpdateInfo, len(updateRecords))
+ for i := range updateRecords {
+ result[updateRecords[i].ID] = buildUpdateInfo(&updateRecords[i])
+ }
+
+ return result, nil
+}
+
func (s *ImageService) ListImagesPaginated(ctx context.Context, params pagination.QueryParams) ([]imagetypes.Summary, pagination.Response, error) {
dockerClient, err := s.dockerService.GetClient()
if err != nil {
diff --git a/backend/internal/services/updater_service.go b/backend/internal/services/updater_service.go
index 6203339a9..9709e7ffb 100644
--- a/backend/internal/services/updater_service.go
+++ b/backend/internal/services/updater_service.go
@@ -300,6 +300,116 @@ func (s *UpdaterService) ApplyPending(ctx context.Context, dryRun bool) (*update
return out, nil
}
+// UpdateSingleContainer updates a single container by ID to the latest available image.
+// It pulls the new image, stops the container, removes it, and recreates it with the new image.
+func (s *UpdaterService) UpdateSingleContainer(ctx context.Context, containerID string) (*updater.Result, error) {
+ start := time.Now()
+ out := &updater.Result{Items: []updater.ResourceResult{}}
+
+ dcli, err := s.dockerService.GetClient()
+ if err != nil {
+ return nil, fmt.Errorf("docker connect: %w", err)
+ }
+
+ // Get container info
+ containers, err := dcli.ContainerList(ctx, container.ListOptions{All: true, Filters: filters.NewArgs(filters.Arg("id", containerID))})
+ if err != nil {
+ return nil, fmt.Errorf("list containers: %w", err)
+ }
+
+ var targetContainer *container.Summary
+ if len(containers) > 0 {
+ targetContainer = &containers[0]
+ }
+
+ if targetContainer == nil {
+ return nil, fmt.Errorf("container not found: %s", containerID)
+ }
+
+ containerName := s.getContainerName(*targetContainer)
+
+ // Get the image reference
+ imageRef := targetContainer.Image
+ normalizedRef := s.normalizeRef(imageRef)
+ repo, tag := s.parseRepoAndTag(normalizedRef)
+
+ if repo == "" || tag == "" {
+ out.Items = append(out.Items, updater.ResourceResult{
+ ResourceID: targetContainer.ID,
+ ResourceType: "container",
+ ResourceName: containerName,
+ Status: "skipped",
+ Error: "invalid image reference",
+ })
+ out.Skipped++
+ out.Duration = time.Since(start).String()
+ return out, nil
+ }
+
+ slog.InfoContext(ctx, "UpdateSingleContainer: pulling new image", "containerID", containerID, "image", normalizedRef)
+
+ // Pull the latest image using the image service
+ if err := s.imageService.PullImage(ctx, normalizedRef, io.Discard, systemUser, nil); err != nil {
+ out.Items = append(out.Items, updater.ResourceResult{
+ ResourceID: targetContainer.ID,
+ ResourceType: "container",
+ ResourceName: containerName,
+ Status: "failed",
+ Error: fmt.Sprintf("pull failed: %v", err),
+ })
+ out.Failed++
+ out.Duration = time.Since(start).String()
+ return out, nil
+ }
+
+ // Inspect container to get full config
+ inspect, err := dcli.ContainerInspect(ctx, targetContainer.ID)
+ if err != nil {
+ out.Items = append(out.Items, updater.ResourceResult{
+ ResourceID: targetContainer.ID,
+ ResourceType: "container",
+ ResourceName: containerName,
+ Status: "failed",
+ Error: fmt.Sprintf("inspect failed: %v", err),
+ })
+ out.Failed++
+ out.Duration = time.Since(start).String()
+ return out, nil
+ }
+
+ // Update the container
+ if err := s.updateContainer(ctx, *targetContainer, inspect, normalizedRef); err != nil {
+ out.Items = append(out.Items, updater.ResourceResult{
+ ResourceID: targetContainer.ID,
+ ResourceType: "container",
+ ResourceName: containerName,
+ Status: "failed",
+ Error: err.Error(),
+ })
+ out.Failed++
+ } else {
+ out.Items = append(out.Items, updater.ResourceResult{
+ ResourceID: targetContainer.ID,
+ ResourceType: "container",
+ ResourceName: containerName,
+ Status: "updated",
+ })
+ out.Updated++
+
+ // Clear the update record for this image
+ if err := s.clearImageUpdateRecord(ctx, repo, tag); err != nil {
+ slog.WarnContext(ctx, "failed to clear update record", "repo", repo, "tag", tag, "err", err)
+ }
+ }
+
+ out.Checked = 1
+ out.Duration = time.Since(start).String()
+
+ slog.InfoContext(ctx, "UpdateSingleContainer: complete", "containerID", containerID, "updated", out.Updated, "failed", out.Failed)
+
+ return out, nil
+}
+
func (s *UpdaterService) pruneImageIDs(ctx context.Context, ids []string) error {
if len(ids) == 0 {
return nil
@@ -426,6 +536,12 @@ func (s *UpdaterService) updateContainer(ctx context.Context, cnt container.Summ
}
_ = s.eventService.LogContainerEvent(ctx, models.EventTypeContainerStart, resp.ID, name, systemUser.ID, systemUser.Username, "0", models.JSON{"action": "updater_start"})
+ _ = s.eventService.LogContainerEvent(ctx, models.EventTypeContainerUpdate, resp.ID, name, systemUser.ID, systemUser.Username, "0", models.JSON{
+ "oldContainerId": cnt.ID,
+ "newContainerId": resp.ID,
+ "newImage": newRef,
+ })
+
slog.DebugContext(ctx, "updateContainer: update complete", "oldContainerId", cnt.ID, "newContainerId", resp.ID)
return nil
}
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index e66ef9c3b..6420344cd 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -305,6 +305,15 @@
"containers_check_updates": "Update Containers",
"containers_check_updates_failed": "Failed to Check Containers for Updates",
"containers_check_updates_success": "Containers Updated Successfully.",
+ "containers_update_column": "Update",
+ "containers_update_container": "Update Container",
+ "containers_update_confirm_title": "Update Container",
+ "containers_update_confirm_message": "This will pull the latest image and restart the container \"{name}\". Do you want to continue?",
+ "containers_update_pulling_image": "Pulling latest image...",
+ "containers_update_recreating": "Recreating container with new image...",
+ "containers_update_success": "Container \"{name}\" updated successfully",
+ "containers_update_failed": "Failed to update container \"{name}\"",
+ "containers_update_available": "Update Available",
"containers_remove_confirm_title": "Confirm Container Removal",
"containers_remove_confirm_message": "Are you sure you want to remove this container? This action cannot be undone.",
"containers_remove_force_label": "Force remove (kill the container if running)",
diff --git a/frontend/src/lib/components/image-update-item.svelte b/frontend/src/lib/components/image-update-item.svelte
index cb7ae4256..2dba3dc69 100644
--- a/frontend/src/lib/components/image-update-item.svelte
+++ b/frontend/src/lib/components/image-update-item.svelte
@@ -9,6 +9,7 @@
import ArrowRightIcon from '@lucide/svelte/icons/arrow-right';
import PackageIcon from '@lucide/svelte/icons/package';
import KeyRoundIcon from '@lucide/svelte/icons/key-round';
+ import ArrowUpCircleIcon from '@lucide/svelte/icons/arrow-up-circle';
import { toast } from 'svelte-sonner';
import type { ImageUpdateData } from '$lib/types/image.type';
import { m } from '$lib/paraglide/messages';
@@ -23,23 +24,46 @@
repo?: string;
tag?: string;
onUpdated?: (data: ImageUpdateData) => void;
+ /** Callback when user clicks "Update Container" button */
+ onUpdateContainer?: () => void;
+ /** Debug: force hasUpdate to true for testing */
+ debugHasUpdate?: boolean;
}
- let { updateInfo = $bindable(), isLoadingInBackground = false, imageId, repo, tag, onUpdated }: Props = $props();
+ let {
+ updateInfo = $bindable(),
+ isLoadingInBackground = false,
+ imageId,
+ repo,
+ tag,
+ onUpdated,
+ onUpdateContainer,
+ debugHasUpdate
+ }: Props = $props();
+
+ // If debug is enabled, override hasUpdate to true
+ const effectiveUpdateInfo = $derived.by((): ImageUpdateData | undefined => {
+ if (!updateInfo) return undefined;
+ if (debugHasUpdate) {
+ return { ...updateInfo, hasUpdate: true, updateType: updateInfo.updateType || 'tag' };
+ }
+ return updateInfo;
+ });
let isChecking = $state(false);
+ let isOpen = $state(false);
const canCheckUpdate = $derived(!!(repo && tag && repo !== '<none>' && tag !== '<none>'));
- const hasError = $derived(!!updateInfo?.error && updateInfo.error.trim() !== '');
+ const hasError = $derived(!!effectiveUpdateInfo?.error && effectiveUpdateInfo.error.trim() !== '');
type AuthBadge = { label: string; classes: string };
const authBadge = $derived.by((): AuthBadge | null => {
- const mth = updateInfo?.authMethod;
+ const mth = effectiveUpdateInfo?.authMethod;
if (!mth) return null;
if (mth === 'credential') {
- const user = updateInfo?.authUsername;
+ const user = effectiveUpdateInfo?.authUsername;
return {
label: user ? m.image_update_auth_credential_with_user({ username: user }) : m.image_update_auth_credential(),
classes: 'border-amber-200/60 text-amber-800 dark:text-amber-300 bg-amber-100 dark:bg-amber-900/30'
@@ -61,16 +85,18 @@
});
const currentVersion = $derived(
- updateInfo?.currentVersion && updateInfo.currentVersion.trim() !== '' ? updateInfo.currentVersion : tag || m.common_unknown()
+ effectiveUpdateInfo?.currentVersion && effectiveUpdateInfo.currentVersion.trim() !== ''
+ ? effectiveUpdateInfo.currentVersion
+ : tag || m.common_unknown()
);
const latestVersion = $derived.by((): string | null => {
if (hasError) return null;
- if (updateInfo?.latestVersion && updateInfo.latestVersion.trim() !== '') {
- return updateInfo.latestVersion;
+ if (effectiveUpdateInfo?.latestVersion && effectiveUpdateInfo.latestVersion.trim() !== '') {
+ return effectiveUpdateInfo.latestVersion;
}
- if (updateInfo?.updateType === 'digest' && updateInfo?.latestDigest) {
- return updateInfo.latestDigest.slice(7, 19) + '...';
+ if (effectiveUpdateInfo?.updateType === 'digest' && effectiveUpdateInfo?.latestDigest) {
+ return effectiveUpdateInfo.latestDigest.slice(7, 19) + '...';
}
return null;
});
@@ -114,20 +140,26 @@
}
}
+ function handleUpdateContainer() {
+ isOpen = false;
+ onUpdateContainer?.();
+ }
+
const updatePriority = $derived.by(() => {
- if (!updateInfo) return null;
- if (updateInfo.error)
+ if (!effectiveUpdateInfo) return null;
+ if (effectiveUpdateInfo.error)
return { level: 'Error', color: 'text-red-500', description: m.image_update_could_not_query_registry() };
- if (!updateInfo.hasUpdate) return { level: 'None', color: 'text-green-500', description: m.image_update_up_to_date_desc() };
- if (updateInfo.updateType === 'digest')
+ if (!effectiveUpdateInfo.hasUpdate)
+ return { level: 'None', color: 'text-green-500', description: m.image_update_up_to_date_desc() };
+ if (effectiveUpdateInfo.updateType === 'digest')
return {
level: m.image_update_digest_title(),
color: 'text-blue-500',
description: m.image_update_digest_desc()
};
- if (updateInfo.updateType === 'tag') {
- const desc = updateInfo.latestVersion
- ? m.image_update_tag_description_new({ version: updateInfo.latestVersion })
+ if (effectiveUpdateInfo.updateType === 'tag') {
+ const desc = effectiveUpdateInfo.latestVersion
+ ? m.image_update_tag_description_new({ version: effectiveUpdateInfo.latestVersion })
: m.image_update_tag_description();
return { level: m.image_update_version_title(), color: 'text-yellow-500', description: desc };
}
@@ -175,19 +207,29 @@
{#snippet recheckButton()}
{#if canCheckUpdate}
<div class="border-t border-gray-200/50 bg-gray-50/50 p-3 dark:border-gray-800/50 dark:bg-gray-900/50">
- <button
- onclick={checkImageUpdate}
- disabled={isChecking}
- class="group flex w-full items-center justify-center gap-2 rounded-lg bg-white/80 px-3 py-2 text-xs font-medium text-gray-700 shadow-sm transition-all hover:bg-white hover:shadow-md disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-800/80 dark:text-gray-300 dark:hover:bg-gray-800"
- >
- {#if isChecking}
- <Spinner class="size-3" />
- {m.common_action_checking()}
- {:else}
- <RefreshCwIcon class="size-3 transition-transform group-hover:rotate-45" />
- {m.image_update_recheck_button()}
- {/if}
- </button>
+ {#if effectiveUpdateInfo?.hasUpdate && onUpdateContainer}
+ <button
+ onclick={handleUpdateContainer}
+ class="group flex w-full items-center justify-center gap-2 rounded-lg bg-blue-500 px-3 py-2 text-xs font-medium text-white shadow-sm transition-all hover:bg-blue-600 hover:shadow-md"
+ >
+ <ArrowUpCircleIcon class="size-3" />
+ {m.containers_update_container()}
+ </button>
+ {:else}
+ <button
+ onclick={checkImageUpdate}
+ disabled={isChecking}
+ class="group flex w-full items-center justify-center gap-2 rounded-lg bg-white/80 px-3 py-2 text-xs font-medium text-gray-700 shadow-sm transition-all hover:bg-white hover:shadow-md disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-800/80 dark:text-gray-300 dark:hover:bg-gray-800"
+ >
+ {#if isChecking}
+ <Spinner class="size-3" />
+ {m.common_action_checking()}
+ {:else}
+ <RefreshCwIcon class="size-3 transition-transform group-hover:rotate-45" />
+ {m.image_update_recheck_button()}
+ {/if}
+ </button>
+ {/if}
</div>
{/if}
{/snippet}
@@ -207,7 +249,7 @@
<div class="space-y-3">
<div class="text-xs text-gray-600 dark:text-gray-300">
<span class="font-medium">{m.image_update_error_label()}</span>
- <span class="ml-1 wrap-break-word">{updateInfo?.error}</span>
+ <span class="ml-1 wrap-break-word">{effectiveUpdateInfo?.error}</span>
</div>
{#if repo && tag}
<div class="text-xs text-gray-500 dark:text-gray-400">
@@ -348,16 +390,16 @@
</div>
{/snippet}
-{#if updateInfo}
+{#if effectiveUpdateInfo}
<Tooltip.Provider>
- <Tooltip.Root>
+ <Tooltip.Root bind:open={isOpen}>
<Tooltip.Trigger>
<span class="mr-2 inline-flex size-4 items-center justify-center align-middle">
{#if hasError}
<TriangleAlertIcon class="size-4 text-red-500" />
- {:else if !updateInfo.hasUpdate}
+ {:else if !effectiveUpdateInfo.hasUpdate}
<CircleCheckIcon class="size-4 text-green-500" />
- {:else if updateInfo.updateType === 'digest'}
+ {:else if effectiveUpdateInfo.updateType === 'digest'}
<CircleArrowUpIcon class="size-4 text-blue-500" />
{:else}
<CircleFadingArrowUpIcon class="size-4 text-yellow-500" />
@@ -373,9 +415,9 @@
<div class="overflow-hidden rounded-xl">
{#if hasError}
{@render errorState()}
- {:else if !updateInfo.hasUpdate}
+ {:else if !effectiveUpdateInfo.hasUpdate}
{@render successState()}
- {:else if updateInfo.updateType === 'digest'}
+ {:else if effectiveUpdateInfo.updateType === 'digest'}
{@render digestUpdateState()}
{:else}
{@render versionUpdateState()}
diff --git a/frontend/src/lib/services/container-service.ts b/frontend/src/lib/services/container-service.ts
index 608a643e4..a5d05060c 100644
--- a/frontend/src/lib/services/container-service.ts
+++ b/frontend/src/lib/services/container-service.ts
@@ -59,6 +59,11 @@ export class ContainerService extends BaseAPIService {
return this.handleResponse(this.api.delete(`/environments/${envId}/containers/${containerId}`, { params }));
}
+
+ async updateContainer(containerId: string): Promise<any> {
+ const envId = await environmentStore.getCurrentEnvironmentId();
+ return this.handleResponse(this.api.post(`/environments/${envId}/containers/${containerId}/update`));
+ }
}
export const containerService = new ContainerService();
diff --git a/frontend/src/lib/types/container.type.ts b/frontend/src/lib/types/container.type.ts
index 18d46c69f..1fceb94b4 100644
--- a/frontend/src/lib/types/container.type.ts
+++ b/frontend/src/lib/types/container.type.ts
@@ -1,5 +1,7 @@
// Base Container Types
+import type { ImageUpdateInfoDto } from './image.type';
+
export interface BaseContainer {
id: string;
names: string[];
@@ -62,6 +64,7 @@ export interface ContainerSummaryDto extends BaseContainer {
hostConfig: ContainerHostConfig;
networkSettings: ContainerNetworkSettings;
mounts: ContainerMounts[];
+ updateInfo?: ImageUpdateInfoDto;
}
export interface ContainerPorts {
diff --git a/frontend/src/routes/(app)/containers/container-table.svelte b/frontend/src/routes/(app)/containers/container-table.svelte
index 0fb9ea8b5..250bd1f71 100644
--- a/frontend/src/routes/(app)/containers/container-table.svelte
+++ b/frontend/src/routes/(app)/containers/container-table.svelte
@@ -6,6 +6,7 @@
import RotateCcwIcon from '@lucide/svelte/icons/rotate-ccw';
import StopCircleIcon from '@lucide/svelte/icons/stop-circle';
import Trash2Icon from '@lucide/svelte/icons/trash-2';
+ import ArrowUpCircleIcon from '@lucide/svelte/icons/arrow-up-circle';
import { Spinner } from '$lib/components/ui/spinner/index.js';
import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
import { goto } from '$app/navigation';
@@ -35,6 +36,7 @@
import FlexRender from '$lib/components/ui/data-table/flex-render.svelte';
import { DataTableViewOptions } from '$lib/components/arcane-table/index.js';
import * as Tooltip from '$lib/components/ui/tooltip/index.js';
+ import ImageUpdateItem from '$lib/components/image-update-item.svelte';
type FieldVisibility = Record<string, boolean>;
@@ -58,6 +60,22 @@
updating: false
});
+ // Parse image reference into repo and tag
+ function parseImageRef(imageRef: string): { repo: string; tag: string } {
+ // Handle images like "nginx:latest", "library/nginx:1.0", "ghcr.io/org/image:tag"
+ const lastColon = imageRef.lastIndexOf(':');
+ // Check if colon is part of a tag (not a port in registry URL)
+ const hasTag = lastColon > 0 && !imageRef.substring(lastColon).includes('/');
+
+ if (hasTag) {
+ return {
+ repo: imageRef.substring(0, lastColon),
+ tag: imageRef.substring(lastColon + 1)
+ };
+ }
+ return { repo: imageRef, tag: 'latest' };
+ }
+
async function performContainerAction(action: string, id: string) {
isLoading[action as keyof typeof isLoading] = true;
@@ -136,6 +154,46 @@
});
}
+ async function handleUpdateContainer(container: ContainerSummaryDto) {
+ const containerName = container.names?.[0]?.replace(/^\//, '') || container.id.substring(0, 12);
+
+ openConfirmDialog({
+ title: m.containers_update_confirm_title(),
+ message: m.containers_update_confirm_message({ name: containerName }),
+ confirm: {
+ label: m.containers_update_container(),
+ action: async () => {
+ isLoading.updating = true;
+ try {
+ toast.info(m.containers_update_pulling_image());
+
+ // Use the new single container update endpoint
+ const result = await containerService.updateContainer(container.id);
+
+ if (result.failed > 0) {
+ const failedItem = result.items?.find((item: any) => item.status === 'failed');
+ toast.error(
+ m.containers_update_failed({ name: containerName }) + (failedItem?.error ? `: ${failedItem.error}` : '')
+ );
+ } else if (result.updated > 0) {
+ toast.success(m.containers_update_success({ name: containerName }));
+ } else {
+ toast.info(m.image_update_up_to_date_title());
+ }
+
+ // Refresh containers
+ containers = await containerService.getContainers(requestOptions);
+ } catch (error) {
+ console.error('Container update failed:', error);
+ toast.error(m.containers_update_failed({ name: containerName }));
+ } finally {
+ isLoading.updating = false;
+ }
+ }
+ }
+ });
+ }
+
const isAnyLoading = $derived(Object.values(isLoading).some((loading) => loading));
const columns = [
@@ -143,6 +201,7 @@
{ accessorKey: 'id', title: m.common_id(), cell: IdCell },
{ accessorKey: 'state', title: m.common_state(), sortable: true, cell: StateCell },
{ accessorKey: 'image', title: m.common_image(), sortable: true, cell: ImageCell },
+ { accessorKey: 'imageId', id: 'update', title: m.containers_update_column(), cell: UpdateCell },
{ accessorKey: 'status', title: m.common_status() },
{ accessorKey: 'ports', title: m.common_ports(), cell: PortsCell },
{ accessorKey: 'created', title: m.common_created(), sortable: true, cell: CreatedCell }
@@ -239,6 +298,18 @@
</span>
{/snippet}
+{#snippet UpdateCell({ item }: { item: ContainerSummaryDto })}
+ {@const imageRef = parseImageRef(item.image)}
+ <ImageUpdateItem
+ updateInfo={item.updateInfo}
+ imageId={item.imageId}
+ repo={imageRef.repo}
+ tag={imageRef.tag}
+ onUpdateContainer={() => handleUpdateContainer(item)}
+ debugHasUpdate={false}
+ />
+{/snippet}
+
{#snippet ContainerMobileCardSnippet({
item,
mobileFieldVisibility
@@ -334,6 +405,17 @@
{m.common_inspect()}
</DropdownMenu.Item>
+ {#if item.updateInfo?.hasUpdate}
+ <DropdownMenu.Item onclick={() => handleUpdateContainer(item)} disabled={isLoading.updating || isAnyLoading}>
+ {#if isLoading.updating}
+ <Spinner class="size-4" />
+ {:else}
+ <ArrowUpCircleIcon class="size-4" />
+ {/if}
+ {m.containers_update_container()}
+ </DropdownMenu.Item>
+ {/if}
+
{#if item.state !== 'running'}
<DropdownMenu.Item onclick={() => performContainerAction('start', item.id)} disabled={isLoading.start || isAnyLoading}>
{#if isLoading.start}
diff --git a/types/container/container.go b/types/container/container.go
index 744883d58..0186300b5 100644
--- a/types/container/container.go
+++ b/types/container/container.go
@@ -7,6 +7,7 @@ import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
containerregistry "go.getarcane.app/types/containerregistry"
+ imagetypes "go.getarcane.app/types/image"
)
// Create is used to create a new container.
@@ -445,6 +446,11 @@ type Summary struct {
//
// Required: true
Mounts []Mount `json:"mounts"`
+
+ // UpdateInfo contains image update information for this container.
+ //
+ // Required: false
+ UpdateInfo *imagetypes.UpdateInfo `json:"updateInfo,omitempty"`
}
// Details represents detailed container information.