Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: add missing kill/pause container actions (#3037)
Kyle Mendelle13ab87df196
diff --git a/backend/api/handlers/containers.go b/backend/api/handlers/containers.goindex 0bf2690cf..f809129f5 100644--- a/backend/api/handlers/containers.go+++ b/backend/api/handlers/containers.go@@ -142,6 +142,13 @@ type SetAutoUpdateOutput struct {Body ContainerActionResponse}+// KillContainerInput carries the optional signal for a container kill.+type KillContainerInput struct {+ EnvironmentID string `path:"id" doc:"Environment ID"`+ ContainerID string `path:"containerId" doc:"Container ID"`+ Signal string `query:"signal" doc:"Signal to send (for example SIGTERM, SIGKILL). Defaults to SIGKILL."`+}+func RegisterContainers(api huma.API, containerSvc *services.ContainerService, dockerSvc *services.DockerClientService, settingsSvc *services.SettingsService, activitySvc *services.ActivityService, appCtx ActivityAppContext) {h := &ContainerHandler{containerService: containerSvc,@@ -215,6 +222,34 @@ func RegisterContainers(api huma.API, containerSvc *services.ContainerService, dSecurity: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}},}, authz.PermContainersRestart, h.RestartContainer)+ humamw.RegisterWithPermission(api, huma.Operation{+ OperationID: "kill-container",+ Method: http.MethodPost,+ Path: "/environments/{id}/containers/{containerId}/kill",+ Summary: "Kill container",+ Description: "Send a signal to the container's main process (default SIGKILL)",+ Tags: []string{"Containers"},+ Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}},+ }, authz.PermContainersKill, h.KillContainer)++ humamw.RegisterWithPermission(api, huma.Operation{+ OperationID: "pause-container",+ Method: http.MethodPost,+ Path: "/environments/{id}/containers/{containerId}/pause",+ Summary: "Pause container",+ Tags: []string{"Containers"},+ Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}},+ }, authz.PermContainersPause, h.PauseContainer)++ humamw.RegisterWithPermission(api, huma.Operation{+ OperationID: "unpause-container",+ Method: http.MethodPost,+ Path: "/environments/{id}/containers/{containerId}/unpause",+ Summary: "Unpause container",+ Tags: []string{"Containers"},+ Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}},+ }, authz.PermContainersPause, h.UnpauseContainer)+humamw.RegisterWithPermission(api, huma.Operation{OperationID: "redeploy-container",Method: http.MethodPost,@@ -632,6 +667,55 @@ func (h *ContainerHandler) RestartContainer(ctx context.Context, input *Containe})}+func (h *ContainerHandler) KillContainer(ctx context.Context, input *KillContainerInput) (*ContainerActionOutput, error) {+ signal := strings.TrimSpace(input.Signal)+ return h.runContainerActionInternal(ctx, &ContainerActionInput{EnvironmentID: input.EnvironmentID, ContainerID: input.ContainerID}, containerActionConfigInternal{+ ActivityType: models.ActivityTypeContainerKill,+ Step: "Killing container",+ StartMessage: "Container kill requested",+ CompleteMessage: "Container killed",+ SuccessMessage: "Container killed successfully",+ Action: func(runtimeCtx context.Context, containerID string, user models.User) error {+ return h.containerService.KillContainer(runtimeCtx, containerID, signal, user)+ },+ Error: func(err error) error {+ return huma.Error500InternalServerError((&common.ContainerKillError{Err: err}).Error())+ },+ })+}++func (h *ContainerHandler) PauseContainer(ctx context.Context, input *ContainerActionInput) (*ContainerActionOutput, error) {+ return h.runContainerActionInternal(ctx, input, containerActionConfigInternal{+ ActivityType: models.ActivityTypeContainerPause,+ Step: "Pausing container",+ StartMessage: "Container pause requested",+ CompleteMessage: "Container paused",+ SuccessMessage: "Container paused successfully",+ Action: func(runtimeCtx context.Context, containerID string, user models.User) error {+ return h.containerService.PauseContainer(runtimeCtx, containerID, user)+ },+ Error: func(err error) error {+ return huma.Error500InternalServerError((&common.ContainerPauseError{Err: err}).Error())+ },+ })+}++func (h *ContainerHandler) UnpauseContainer(ctx context.Context, input *ContainerActionInput) (*ContainerActionOutput, error) {+ return h.runContainerActionInternal(ctx, input, containerActionConfigInternal{+ ActivityType: models.ActivityTypeContainerUnpause,+ Step: "Unpausing container",+ StartMessage: "Container unpause requested",+ CompleteMessage: "Container unpaused",+ SuccessMessage: "Container unpaused successfully",+ Action: func(runtimeCtx context.Context, containerID string, user models.User) error {+ return h.containerService.UnpauseContainer(runtimeCtx, containerID, user)+ },+ Error: func(err error) error {+ return huma.Error500InternalServerError((&common.ContainerUnpauseError{Err: err}).Error())+ },+ })+}+type containerActionConfigInternal struct {ActivityType models.ActivityTypeStep stringdiff --git a/backend/internal/common/errors.go b/backend/internal/common/errors.goindex b215b6368..8ef80094b 100644--- a/backend/internal/common/errors.go+++ b/backend/internal/common/errors.go@@ -241,6 +241,30 @@ func (e *ContainerRestartError) Error() string {return fmt.Sprintf("Failed to restart container: %v", e.Err)}+type ContainerKillError struct {+ Err error+}++func (e *ContainerKillError) Error() string {+ return fmt.Sprintf("Failed to kill container: %v", e.Err)+}++type ContainerPauseError struct {+ Err error+}++func (e *ContainerPauseError) Error() string {+ return fmt.Sprintf("Failed to pause container: %v", e.Err)+}++type ContainerUnpauseError struct {+ Err error+}++func (e *ContainerUnpauseError) Error() string {+ return fmt.Sprintf("Failed to unpause container: %v", e.Err)+}+type ContainerRedeployError struct {Err error}diff --git a/backend/internal/models/activity.go b/backend/internal/models/activity.goindex 3aaa27205..0400d1b88 100644--- a/backend/internal/models/activity.go+++ b/backend/internal/models/activity.go@@ -32,6 +32,9 @@ const (ActivityTypeContainerRestart ActivityType = "container_restart"ActivityTypeContainerRedeploy ActivityType = "container_redeploy"ActivityTypeContainerDelete ActivityType = "container_delete"+ ActivityTypeContainerKill ActivityType = "container_kill"+ ActivityTypeContainerPause ActivityType = "container_pause"+ ActivityTypeContainerUnpause ActivityType = "container_unpause"ActivityTypeVulnerabilityScan ActivityType = "vulnerability_scan"ActivityTypeAutoUpdate ActivityType = "auto_update"ActivityTypeSystemPrune ActivityType = "system_prune"diff --git a/backend/internal/models/event.go b/backend/internal/models/event.goindex 9d15cc7a3..40e9ec4a9 100644--- a/backend/internal/models/event.go+++ b/backend/internal/models/event.go@@ -19,6 +19,9 @@ const (EventTypeContainerScan EventType = "container.scan"EventTypeContainerUpdate EventType = "container.update"EventTypeContainerDeploy EventType = "container.deploy"+ EventTypeContainerKill EventType = "container.kill"+ EventTypeContainerPause EventType = "container.pause"+ EventTypeContainerUnpause EventType = "container.unpause"EventTypeContainerError EventType = "container.error"EventTypeImagePull EventType = "image.pull"diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.goindex 49af2b2f4..c778efe4e 100644--- a/backend/internal/services/container_service.go+++ b/backend/internal/services/container_service.go@@ -7,6 +7,7 @@ import ("fmt""io""log/slog"+ "maps""slices""strings""sync"@@ -278,76 +279,115 @@ func (s *ContainerService) restoreContainerAfterRedeployFailureInternal(ctx cont}}-func (s *ContainerService) StartContainer(ctx context.Context, containerID string, user models.User) error {+type containerLifecycleActionInternal struct {+ action string+ eventType models.EventType+ metadata models.JSON+ warnOnLogError bool+ runContainerAction func(*client.Client) error+}++func (s *ContainerService) runContainerLifecycleActionInternal(ctx context.Context, containerID string, user models.User, cfg containerLifecycleActionInternal) error {dockerClient, err := s.dockerService.GetClient(ctx)if err != nil {- s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, "", user.ID, user.Username, "0", err, models.JSON{"action": "start"})+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, "", user.ID, user.Username, "0", err, models.JSON{"action": cfg.action})return fmt.Errorf("failed to connect to Docker: %w", err)}metadata := models.JSON{- "action": "start",+ "action": cfg.action,"containerId": containerID,}+ maps.Copy(metadata, cfg.metadata)- err = s.eventService.LogContainerEvent(ctx, models.EventTypeContainerStart, containerID, "name", user.ID, user.Username, "0", metadata)+ err = s.eventService.LogContainerEvent(ctx, cfg.eventType, containerID, "name", user.ID, user.Username, "0", metadata)if err != nil {- slog.WarnContext(ctx, "could not log container start action", "error", err)+ if !cfg.warnOnLogError {+ return fmt.Errorf("failed to log action: %w", err)+ }+ slog.WarnContext(ctx, "could not log container action", "action", cfg.action, "error", err)}- _, err = dockerClient.ContainerStart(ctx, containerID, client.ContainerStartOptions{})+ err = cfg.runContainerAction(dockerClient)if err != nil {- s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, "", user.ID, user.Username, "0", err, models.JSON{"action": "start"})+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, "", user.ID, user.Username, "0", err, models.JSON{"action": cfg.action})}return err}-func (s *ContainerService) StopContainer(ctx context.Context, containerID string, user models.User) error {- dockerClient, err := s.dockerService.GetClient(ctx)- if err != nil {- s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, "", user.ID, user.Username, "0", err, models.JSON{"action": "stop"})- return fmt.Errorf("failed to connect to Docker: %w", err)- }-- metadata := models.JSON{- "action": "stop",- "containerId": containerID,- }-- err = s.eventService.LogContainerEvent(ctx, models.EventTypeContainerStop, containerID, "name", user.ID, user.Username, "0", metadata)- if err != nil {- return fmt.Errorf("failed to log action: %w", err)- }+func (s *ContainerService) StartContainer(ctx context.Context, containerID string, user models.User) error {+ return s.runContainerLifecycleActionInternal(ctx, containerID, user, containerLifecycleActionInternal{+ action: "start",+ eventType: models.EventTypeContainerStart,+ warnOnLogError: true,+ runContainerAction: func(dockerClient *client.Client) error {+ _, err := dockerClient.ContainerStart(ctx, containerID, client.ContainerStartOptions{})+ return err+ },+ })+}- _, err = dockerClient.ContainerStop(ctx, containerID, client.ContainerStopOptions{Timeout: new(30)})- if err != nil {- s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, "", user.ID, user.Username, "0", err, models.JSON{"action": "stop"})- }- return err+func (s *ContainerService) StopContainer(ctx context.Context, containerID string, user models.User) error {+ return s.runContainerLifecycleActionInternal(ctx, containerID, user, containerLifecycleActionInternal{+ action: "stop",+ eventType: models.EventTypeContainerStop,+ runContainerAction: func(dockerClient *client.Client) error {+ _, err := dockerClient.ContainerStop(ctx, containerID, client.ContainerStopOptions{Timeout: new(30)})+ return err+ },+ })}func (s *ContainerService) RestartContainer(ctx context.Context, containerID string, user models.User) error {- dockerClient, err := s.dockerService.GetClient(ctx)- if err != nil {- s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, "", user.ID, user.Username, "0", err, models.JSON{"action": "restart"})- return fmt.Errorf("failed to connect to Docker: %w", err)- }+ return s.runContainerLifecycleActionInternal(ctx, containerID, user, containerLifecycleActionInternal{+ action: "restart",+ eventType: models.EventTypeContainerRestart,+ runContainerAction: func(dockerClient *client.Client) error {+ _, err := dockerClient.ContainerRestart(ctx, containerID, client.ContainerRestartOptions{})+ return err+ },+ })+}- metadata := models.JSON{- "action": "restart",- "containerId": containerID,- }+// KillContainer sends a signal to the container's main process (default SIGKILL+// when signal is empty) without removing the container.+func (s *ContainerService) KillContainer(ctx context.Context, containerID, signal string, user models.User) error {+ return s.runContainerLifecycleActionInternal(ctx, containerID, user, containerLifecycleActionInternal{+ action: "kill",+ eventType: models.EventTypeContainerKill,+ metadata: models.JSON{"signal": signal},+ warnOnLogError: true,+ runContainerAction: func(dockerClient *client.Client) error {+ _, err := dockerClient.ContainerKill(ctx, containerID, client.ContainerKillOptions{Signal: signal})+ return err+ },+ })+}- err = s.eventService.LogContainerEvent(ctx, models.EventTypeContainerRestart, containerID, "name", user.ID, user.Username, "0", metadata)- if err != nil {- return fmt.Errorf("failed to log action: %w", err)- }+// PauseContainer suspends all processes in the container.+func (s *ContainerService) PauseContainer(ctx context.Context, containerID string, user models.User) error {+ return s.runContainerLifecycleActionInternal(ctx, containerID, user, containerLifecycleActionInternal{+ action: "pause",+ eventType: models.EventTypeContainerPause,+ warnOnLogError: true,+ runContainerAction: func(dockerClient *client.Client) error {+ _, err := dockerClient.ContainerPause(ctx, containerID, client.ContainerPauseOptions{})+ return err+ },+ })+}- _, err = dockerClient.ContainerRestart(ctx, containerID, client.ContainerRestartOptions{})- if err != nil {- s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, "", user.ID, user.Username, "0", err, models.JSON{"action": "restart"})- }- return err+// UnpauseContainer resumes a previously paused container.+func (s *ContainerService) UnpauseContainer(ctx context.Context, containerID string, user models.User) error {+ return s.runContainerLifecycleActionInternal(ctx, containerID, user, containerLifecycleActionInternal{+ action: "unpause",+ eventType: models.EventTypeContainerUnpause,+ warnOnLogError: true,+ runContainerAction: func(dockerClient *client.Client) error {+ _, err := dockerClient.ContainerUnpause(ctx, containerID, client.ContainerUnpauseOptions{})+ return err+ },+ })}// tryRedeployViaComposeProjectInternal attempts to redeploy a compose-manageddiff --git a/backend/pkg/authz/catalog.go b/backend/pkg/authz/catalog.goindex d3b28ade5..311bf9649 100644--- a/backend/pkg/authz/catalog.go+++ b/backend/pkg/authz/catalog.go@@ -105,6 +105,8 @@ var permissionCatalog = []PermissionCatalogResource{{"stop", PermContainersStop, "Stop", ""},{"restart", PermContainersRestart, "Restart", ""},{"redeploy", PermContainersRedeploy, "Redeploy", ""},+ {"kill", PermContainersKill, "Kill (send signal)", ""},+ {"pause", PermContainersPause, "Pause / unpause", ""},{"delete", PermContainersDelete, "Delete", ""},{"exec", PermContainersExec, "Exec / terminal", ""},{"autoupdate", PermContainersAutoUpdate, "Auto-update", ""},diff --git a/backend/pkg/authz/permissions.go b/backend/pkg/authz/permissions.goindex ebe3d1a76..0dfa2d7c0 100644--- a/backend/pkg/authz/permissions.go+++ b/backend/pkg/authz/permissions.go@@ -97,6 +97,8 @@ const (PermContainersStop = "containers:stop"PermContainersRestart = "containers:restart"PermContainersRedeploy = "containers:redeploy"+ PermContainersKill = "containers:kill"+ PermContainersPause = "containers:pause"PermContainersDelete = "containers:delete"PermContainersExec = "containers:exec"PermContainersAutoUpdate = "containers:autoupdate"@@ -278,7 +280,7 @@ func BuiltInEditorPermissions() []string {PermGitReposList, PermGitReposRead,PermEventsRead,// Full env-scoped Docker management- PermContainersList, PermContainersRead, PermContainersLogs, PermContainersCreate, PermContainersStart, PermContainersStop, PermContainersRestart, PermContainersRedeploy, PermContainersDelete, PermContainersExec, PermContainersAutoUpdate,+ PermContainersList, PermContainersRead, PermContainersLogs, PermContainersCreate, PermContainersStart, PermContainersStop, PermContainersRestart, PermContainersRedeploy, PermContainersKill, PermContainersPause, PermContainersDelete, PermContainersExec, PermContainersAutoUpdate,PermProjectsList, PermProjectsRead, PermProjectsLogs, PermProjectsCreate, PermProjectsUpdate, PermProjectsDeploy, PermProjectsDown, PermProjectsRestart, PermProjectsDelete, PermProjectsArchive,PermImagesList, PermImagesRead, PermImagesPull, PermImagesPush, PermImagesBuild, PermImagesPrune, PermImagesDelete, PermImagesUpload,PermVolumesList, PermVolumesRead, PermVolumesCreate, PermVolumesDelete, PermVolumesPrune, PermVolumesBrowse, PermVolumesUpload, PermVolumesBackup,@@ -304,7 +306,7 @@ func BuiltInDeployerPermissions() []string {PermRegistriesList, PermRegistriesRead,PermTemplatesList, PermTemplatesRead,PermEventsRead,- PermContainersList, PermContainersRead, PermContainersLogs, PermContainersStart, PermContainersStop, PermContainersRestart, PermContainersRedeploy,+ PermContainersList, PermContainersRead, PermContainersLogs, PermContainersStart, PermContainersStop, PermContainersRestart, PermContainersRedeploy, PermContainersKill, PermContainersPause,PermProjectsList, PermProjectsRead, PermProjectsLogs, PermProjectsDeploy, PermProjectsDown, PermProjectsRestart,PermImagesList, PermImagesRead, PermImagesPull,PermVolumesList, PermVolumesRead, PermVolumesBrowse,diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 85e397731..2b30a97bf 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -122,6 +122,9 @@"common_start": "Start","common_restart": "Restart","common_stop": "Stop",+ "common_pause": "Pause",+ "common_unpause": "Unpause",+ "common_kill": "Kill","common_up": "Up","common_down": "Down","common_retry": "Retry",@@ -272,6 +275,9 @@"common_action_deploying": "Deploying…","common_action_downloading": "Downloading…","common_action_restarting": "Restarting…",+ "common_action_pausing": "Pausing…",+ "common_action_unpausing": "Unpausing…",+ "common_action_killing": "Killing…","common_action_removing": "Removing…","common_action_updating": "Updating…","common_action_redeploying": "Redeploying…",@@ -491,6 +497,16 @@"containers_stop_success": "Container stopped successfully","containers_restart_failed": "Failed to restart container","containers_restart_success": "Container restarted successfully",+ "containers_pause_failed": "Failed to pause container",+ "containers_pause_success": "Container paused successfully",+ "containers_unpause_failed": "Failed to unpause container",+ "containers_unpause_success": "Container unpaused successfully",+ "containers_kill_title": "Kill \"{name}\"",+ "containers_kill_description": "Send a signal to the container's main process. The container is not removed.",+ "containers_kill_signal_label": "Signal",+ "containers_kill_confirm": "Kill container",+ "containers_kill_failed": "Failed to kill container \"{name}\"",+ "containers_kill_success": "Signal sent to container \"{name}\"","containers_check_updates": "Update Containers","containers_check_updates_failed": "Failed to Check Containers for Updates","containers_check_updates_success": "Containers Updated Successfully.",diff --git a/frontend/src/lib/components/action-buttons.svelte b/frontend/src/lib/components/action-buttons.svelteindex 5ce99f0db..e8000b789 100644--- a/frontend/src/lib/components/action-buttons.svelte+++ b/frontend/src/lib/components/action-buttons.svelte@@ -1,11 +1,12 @@<script lang="ts">import { onMount } from 'svelte';+ import type { Snippet } from 'svelte';import { openConfirmDialog } from './confirm-dialog';import { goto, invalidateAll } from '$app/navigation';import { toast } from 'svelte-sonner';import { tryCatch } from '$lib/utils/api';import { handleApiResultWithCallbacks } from '$lib/utils/api';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';+ import { ArcaneButton, type ArcaneButtonSize } from '$lib/components/arcane-button/index.js';import DeploySplitButton from '$lib/components/deploy-split-button/deploy-split-button.svelte';import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';import { m } from '$lib/paraglide/messages';@@ -49,7 +50,9 @@refreshLoading = $bindable(false),hasBuildDirective = false,disableRedeploy = false,- onRefresh+ onRefresh,+ beforeRemoveActions,+ beforeRemoveMenuItems}: {id: string;name?: string;@@ -67,6 +70,8 @@hasBuildDirective?: boolean;disableRedeploy?: boolean;onRefresh?: () => void | Promise<void>;+ beforeRemoveActions?: Snippet<[ArcaneButtonSize, boolean, boolean]>;+ beforeRemoveMenuItems?: Snippet<[boolean]>;} = $props();let isLoading = $state<LoadingStates>({@@ -110,6 +115,9 @@validating: !!(isLoading.validating || loading?.validating),refresh: !!(isLoading.refresh || loading?.refresh || refreshLoading)});+ const isLifecycleActionPending = $derived(+ !!(uiLoading.start || uiLoading.stop || uiLoading.restart || uiLoading.redeploy || uiLoading.remove)+ );const startMutation = createMutation(() => ({mutationKey: ['action', 'start', type, id],@@ -471,6 +479,7 @@{#if type === 'container'}{@render RedeployActionButton(adaptiveIconOnly ? 'icon' : 'default', !adaptiveIconOnly)}+ {@render beforeRemoveActions?.(adaptiveIconOnly ? 'icon' : 'default', !adaptiveIconOnly, isLifecycleActionPending)}{#if canRemove}<ArcaneButtonaction="remove"@@ -585,6 +594,7 @@{#if type === 'container'}{@render RedeployMenuItem()}+ {@render beforeRemoveMenuItems?.(isLifecycleActionPending)}{#if canRemove}<DropdownMenu.Item onclick={() => confirmAction('remove')} disabled={uiLoading.remove}>{m.common_remove()}@@ -651,6 +661,7 @@{#if type === 'container'}{@render RedeployActionButton()}+ {@render beforeRemoveActions?.('default', true, isLifecycleActionPending)}{#if canRemove}<ArcaneButton action="remove" onclick={() => confirmAction('remove')} loading={uiLoading.remove} />{/if}@@ -739,6 +750,7 @@{#if type === 'container'}{@render RedeployMenuItem()}+ {@render beforeRemoveMenuItems?.(isLifecycleActionPending)}{#if canRemove}<DropdownMenu.Item onclick={() => confirmAction('remove')} disabled={uiLoading.remove}>{m.common_remove()}diff --git a/frontend/src/lib/components/arcane-button/variants.ts b/frontend/src/lib/components/arcane-button/variants.tsindex 348c21793..f9ad61cc7 100644--- a/frontend/src/lib/components/arcane-button/variants.ts+++ b/frontend/src/lib/components/arcane-button/variants.ts@@ -22,7 +22,10 @@ import {OpenIdIcon,RedeployIcon,CodeIcon,- HammerIcon+ HammerIcon,+ PauseIcon,+ PlayIcon,+ ZapIcon} from '$lib/icons';export const arcaneButtonVariants = tv({@@ -55,6 +58,10 @@ export const arcaneButtonVariants = tv({'bg-sky-500/5 text-foreground! border-sky-500/20 hover:bg-sky-500/10 hover:border-sky-500/40 ' +'dark:bg-sky-500/10 dark:text-sky-400 dark:border-sky-500/30 dark:hover:bg-sky-500/20 ' +'shadow-sm hover:shadow-md',+ 'outline-warning':+ 'bg-amber-500/5 text-foreground! border-amber-500/20 hover:bg-amber-500/10 hover:border-amber-500/40 ' ++ 'dark:bg-amber-500/10 dark:text-amber-300 dark:border-amber-500/30 dark:hover:bg-amber-500/20 ' ++ 'shadow-sm hover:shadow-md','outline-build':'bg-violet-500/5 text-foreground! border-violet-500/20 hover:bg-violet-500/10 hover:border-violet-500/40 ' +'dark:bg-violet-500/10 dark:text-violet-300 dark:border-violet-500/30 dark:hover:bg-violet-500/20 ' +@@ -136,6 +143,24 @@ export const actionConfigs = {tone: 'outline-info',loadingLabel: m.common_action_stopping()},+ pause: {+ defaultLabel: m.common_pause(),+ IconComponent: PauseIcon,+ tone: 'outline-warning',+ loadingLabel: m.common_processing()+ },+ unpause: {+ defaultLabel: m.common_unpause(),+ IconComponent: PlayIcon,+ tone: 'outline-success',+ loadingLabel: m.common_processing()+ },+ kill: {+ defaultLabel: m.common_kill(),+ IconComponent: ZapIcon,+ tone: 'outline-destructive',+ loadingLabel: m.common_action_killing()+ },remove: {defaultLabel: m.common_remove(),IconComponent: TrashIcon,diff --git a/frontend/src/lib/icons/index.ts b/frontend/src/lib/icons/index.tsindex baa0ef6f7..8e43c0b42 100644--- a/frontend/src/lib/icons/index.ts+++ b/frontend/src/lib/icons/index.ts@@ -22,6 +22,9 @@ export { default as UsersIcon } from 'virtual:icons/material-symbols/person-textexport { default as NotificationsIcon } from 'virtual:icons/ic/round-notifications-active';export { default as InfoIcon } from 'virtual:icons/pepicons-pop/info-circle';export { default as CpuIcon } from 'virtual:icons/solar/cpu-outline';+export { default as PauseIcon } from 'virtual:icons/lucide/pause';+export { default as PlayIcon } from 'virtual:icons/lucide/play';+export { default as ZapIcon } from 'virtual:icons/lucide/zap';export { default as MemoryStickIcon } from 'virtual:icons/fluent/memory-16-regular';export { default as ArrowDownIcon } from 'virtual:icons/ic/baseline-keyboard-arrow-down';export { default as ArrowUpIcon } from 'virtual:icons/ic/baseline-keyboard-arrow-up';diff --git a/frontend/src/lib/services/container-service.ts b/frontend/src/lib/services/container-service.tsindex 09c774493..aa483dcb6 100644--- a/frontend/src/lib/services/container-service.ts+++ b/frontend/src/lib/services/container-service.ts@@ -54,12 +54,12 @@ class ContainerService extends BaseAPIService {return res.data.data;}- async getContainer(containerId: string): Promise<any> {+ async getContainer(containerId: string): Promise<ContainerDetailsDto> {const envId = await this.resolveEnvironmentId();return this.getContainerForEnvironment(envId, containerId);}- async getContainerForEnvironment(environmentId: string, containerId: string): Promise<any> {+ async getContainerForEnvironment(environmentId: string, containerId: string): Promise<ContainerDetailsDto> {return this.handleResponse(this.api.get(`/environments/${environmentId}/containers/${containerId}`));}@@ -83,6 +83,23 @@ class ContainerService extends BaseAPIService {return this.handleResponse(this.api.post(`/environments/${envId}/containers/${containerId}/restart`));}+ async killContainer(containerId: string, signal?: string): Promise<any> {+ const envId = await environmentStore.getCurrentEnvironmentId();+ const params: Record<string, string> = {};+ if (signal) params['signal'] = signal;+ return this.handleResponse(this.api.post(`/environments/${envId}/containers/${containerId}/kill`, undefined, { params }));+ }++ async pauseContainer(containerId: string): Promise<any> {+ const envId = await environmentStore.getCurrentEnvironmentId();+ return this.handleResponse(this.api.post(`/environments/${envId}/containers/${containerId}/pause`));+ }++ async unpauseContainer(containerId: string): Promise<any> {+ const envId = await environmentStore.getCurrentEnvironmentId();+ return this.handleResponse(this.api.post(`/environments/${envId}/containers/${containerId}/unpause`));+ }+async deleteContainer(containerId: string, opts?: { force?: boolean; volumes?: boolean }): Promise<any> {const envId = await environmentStore.getCurrentEnvironmentId();const params: Record<string, string> = {};diff --git a/frontend/src/lib/utils/container-actions.ts b/frontend/src/lib/utils/container-actions.tsindex e77f2a027..e9dd67e94 100644--- a/frontend/src/lib/utils/container-actions.ts+++ b/frontend/src/lib/utils/container-actions.ts@@ -5,8 +5,8 @@ import { handleApiResultWithCallbacks, tryCatch } from '$lib/utils/api';import { activityToastOptions, extractActivityId } from '$lib/utils/activity-toast';import { toast } from 'svelte-sonner';-type ContainerLifecycleAction = 'start' | 'stop' | 'restart';-type ContainerLifecycleStatus = 'starting' | 'stopping' | 'restarting' | '';+type ContainerLifecycleAction = 'start' | 'stop' | 'restart' | 'pause' | 'unpause';+type ContainerLifecycleStatus = 'starting' | 'stopping' | 'restarting' | 'pausing' | 'unpausing' | '';type ContainerRemoveStatus = 'removing' | '';type ContainerLifecycleActionConfig = {@@ -34,6 +34,18 @@ const containerLifecycleActionConfigs: Record<ContainerLifecycleAction, Containerun: (id) => containerService.restartContainer(id),success: () => m.containers_restart_success(),failure: () => m.containers_restart_failed()+ },+ pause: {+ status: 'pausing',+ run: (id) => containerService.pauseContainer(id),+ success: () => m.containers_pause_success(),+ failure: () => m.containers_pause_failed()+ },+ unpause: {+ status: 'unpausing',+ run: (id) => containerService.unpauseContainer(id),+ success: () => m.containers_unpause_success(),+ failure: () => m.containers_unpause_failed()}};diff --git a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte b/frontend/src/routes/(app)/containers/[containerId]/+page.svelteindex 1e155758b..8215b8886 100644--- a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte+++ b/frontend/src/routes/(app)/containers/[containerId]/+page.svelte@@ -44,6 +44,10 @@import { projectService } from '$lib/services/project-service';import { environmentStore } from '$lib/stores/environment.store.svelte';import { hasPermission } from '$lib/utils/auth';+ import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';+ import { PauseIcon, PlayIcon, ZapIcon } from '$lib/icons';+ import { runContainerLifecycleAction } from '$lib/utils/container-actions';+ import KillContainerDialog from '../components/kill-container-dialog.svelte';let { data } = $props();let container = $derived(data?.container as ContainerDetailsDto);let stats = $state(null as ContainerStatsType | null);@@ -137,9 +141,42 @@);const showNetworkTab = $derived(hasNetworks || hasPorts);const hasMounts = $derived(!!(container?.mounts && container.mounts.length > 0));- const currentEnvId = $derived(environmentStore.selected?.id);+ const currentEnvId = $derived(environmentStore.selected?.id || '0');const canViewLogs = $derived(hasPermission('containers:logs', currentEnvId));const canExecShell = $derived(hasPermission('containers:exec', currentEnvId));+ const canPauseContainer = $derived(hasPermission('containers:pause', currentEnvId));+ const canKillContainer = $derived(hasPermission('containers:kill', currentEnvId));+ const containerStatus = $derived(container?.state?.status ?? '');+ const isContainerRunning = $derived(containerStatus === 'running' || !!container?.state?.running);+ const isContainerPaused = $derived(containerStatus === 'paused');++ let killDialogOpen = $state(false);+ let lifecycleStatus = $state<'pausing' | 'unpausing' | ''>('');+ const isLifecycleActionPending = $derived(lifecycleStatus !== '');++ async function handlePauseContainer() {+ if (!container || isLifecycleActionPending) return;+ await runContainerLifecycleAction({+ action: 'pause',+ containerId: container.id,+ setStatus: (status) => {+ lifecycleStatus = status === 'pausing' ? status : '';+ },+ onRefresh: () => invalidateAll()+ });+ }++ async function handleUnpauseContainer() {+ if (!container || isLifecycleActionPending) return;+ await runContainerLifecycleAction({+ action: 'unpause',+ containerId: container.id,+ setStatus: (status) => {+ lifecycleStatus = status === 'unpausing' ? status : '';+ },+ onRefresh: () => invalidateAll()+ });+ }const showStats = $derived(!!container?.state?.running);const showShell = $derived(!!container?.state?.running && canExecShell);const hasHealthcheck = $derived(@@ -289,14 +326,76 @@{/snippet}{#snippet headerActions()}- <ActionButtons- id={container.id}- name={containerDisplayName}- type="container"- itemState={container.state?.running ? 'running' : 'stopped'}- desktopVariant="adaptive"- disableRedeploy={!!container.redeployDisabled}- />+ <div class="container-detail-actions">+ <ActionButtons+ id={container.id}+ name={containerDisplayName}+ type="container"+ itemState={container.state?.running ? 'running' : 'stopped'}+ desktopVariant="adaptive"+ disableRedeploy={!!container.redeployDisabled}+ >+ {#snippet beforeRemoveActions(size, showLabel, actionButtonsLifecyclePending)}+ {#if canPauseContainer && isContainerPaused}+ <ArcaneButton+ action="unpause"+ {size}+ {showLabel}+ loading={lifecycleStatus === 'unpausing'}+ disabled={isLifecycleActionPending || actionButtonsLifecyclePending}+ onclick={handleUnpauseContainer}+ />+ {:else if canPauseContainer && isContainerRunning}+ <ArcaneButton+ action="pause"+ {size}+ {showLabel}+ loading={lifecycleStatus === 'pausing'}+ disabled={isLifecycleActionPending || actionButtonsLifecyclePending}+ onclick={handlePauseContainer}+ />+ {/if}+ {#if canKillContainer && (isContainerRunning || isContainerPaused)}+ <ArcaneButton+ action="kill"+ {size}+ {showLabel}+ disabled={isLifecycleActionPending || actionButtonsLifecyclePending}+ onclick={() => (killDialogOpen = true)}+ />+ {/if}+ {/snippet}++ {#snippet beforeRemoveMenuItems(actionButtonsLifecyclePending)}+ {#if canPauseContainer && isContainerPaused}+ <DropdownMenu.Item+ disabled={isLifecycleActionPending || actionButtonsLifecyclePending}+ onclick={handleUnpauseContainer}+ >+ <PlayIcon class="size-4" />+ {m.common_unpause()}+ </DropdownMenu.Item>+ {:else if canPauseContainer && isContainerRunning}+ <DropdownMenu.Item+ disabled={isLifecycleActionPending || actionButtonsLifecyclePending}+ onclick={handlePauseContainer}+ >+ <PauseIcon class="size-4" />+ {m.common_pause()}+ </DropdownMenu.Item>+ {/if}+ {#if canKillContainer && (isContainerRunning || isContainerPaused)}+ <DropdownMenu.Item+ disabled={isLifecycleActionPending || actionButtonsLifecyclePending}+ onclick={() => (killDialogOpen = true)}+ >+ <ZapIcon class="size-4" />+ {m.common_kill()}+ </DropdownMenu.Item>+ {/if}+ {/snippet}+ </ActionButtons>+ </div>{/snippet}{#snippet tabContent(activeTab)}@@ -395,6 +494,15 @@</Tabs.Content>{/snippet}</TabbedPageLayout>++ {#if killDialogOpen && canKillContainer && (isContainerRunning || isContainerPaused)}+ <KillContainerDialog+ containerId={container.id}+ containerName={containerDisplayName}+ onClose={() => (killDialogOpen = false)}+ onComplete={() => invalidateAll()}+ />+ {/if}{:else}<div class="flex min-h-screen items-center justify-center"><div class="text-center">@@ -417,3 +525,14 @@</div></div>{/if}++<style>+ .container-detail-actions {+ display: flex;+ flex: 1 1 auto;+ min-width: 0;+ align-items: center;+ justify-content: flex-end;+ gap: 0.5rem;+ }+</style>diff --git a/frontend/src/routes/(app)/containers/components/kill-container-dialog.svelte b/frontend/src/routes/(app)/containers/components/kill-container-dialog.sveltenew file mode 100644index 000000000..a8245b49a--- /dev/null+++ b/frontend/src/routes/(app)/containers/components/kill-container-dialog.svelte@@ -0,0 +1,85 @@+<script lang="ts">+ import { ArcaneButton } from '$lib/components/arcane-button';+ import * as ResponsiveDialog from '$lib/components/ui/responsive-dialog';+ import * as Select from '$lib/components/ui/select';+ import { Label } from '$lib/components/ui/label';+ import { m } from '$lib/paraglide/messages';+ import { toast } from 'svelte-sonner';+ import { containerService } from '$lib/services/container-service';+ import { handleApiResultWithCallbacks, tryCatch } from '$lib/utils/api';+ import { activityToastOptions, extractActivityId } from '$lib/utils/activity-toast';++ type Props = {+ containerId: string;+ containerName: string;+ onClose?: () => void;+ onComplete?: () => void | Promise<void>;+ };++ let { containerId, containerName, onClose, onComplete }: Props = $props();++ const SIGNALS = ['SIGKILL', 'SIGTERM', 'SIGINT', 'SIGHUP', 'SIGQUIT'];+ let open = $state(true);+ let signal = $state('SIGKILL');+ let isSubmitting = $state(false);++ async function handleConfirm() {+ if (!containerId) return;+ isSubmitting = true;+ handleApiResultWithCallbacks({+ result: await tryCatch(containerService.killContainer(containerId, signal)),+ message: m.containers_kill_failed({ name: containerName }),+ setLoadingState: (value) => {+ isSubmitting = value;+ },+ async onSuccess(data) {+ toast.success(m.containers_kill_success({ name: containerName }), activityToastOptions(extractActivityId(data)));+ open = false;+ await onComplete?.();+ }+ });+ }+</script>++<ResponsiveDialog.Root+ bind:open+ onOpenChange={(value) => {+ if (!value) onClose?.();+ }}+ title={m.containers_kill_title({ name: containerName })}+ description={m.containers_kill_description()}+>+ <div class="space-y-2 px-6 py-4">+ <Label for="kill-signal">{m.containers_kill_signal_label()}</Label>+ <Select.Root type="single" bind:value={signal}>+ <Select.Trigger id="kill-signal" class="w-full">+ <span class="truncate">{signal}</span>+ </Select.Trigger>+ <Select.Content>+ {#each SIGNALS as sig (sig)}+ <Select.Item value={sig}>{sig}</Select.Item>+ {/each}+ </Select.Content>+ </Select.Root>+ </div>++ {#snippet footer()}+ <div class="flex w-full flex-col gap-2 px-6 pb-6 sm:flex-row sm:justify-end">+ <ArcaneButton+ action="base"+ tone="outline"+ customLabel={m.common_cancel()}+ onclick={() => (open = false)}+ disabled={isSubmitting}+ />+ <ArcaneButton+ action="base"+ tone="outline-destructive"+ customLabel={m.containers_kill_confirm()}+ onclick={handleConfirm}+ loading={isSubmitting}+ disabled={isSubmitting}+ />+ </div>+ {/snippet}+</ResponsiveDialog.Root>diff --git a/frontend/src/routes/(app)/containers/container-table.actions.ts b/frontend/src/routes/(app)/containers/container-table.actions.tsindex c1b386011..a4076b3e0 100644--- a/frontend/src/routes/(app)/containers/container-table.actions.ts+++ b/frontend/src/routes/(app)/containers/container-table.actions.ts@@ -26,12 +26,15 @@ type ActionDeps = {isBulkLoading: BulkLoadingState;};-type ContainerActionKind = 'start' | 'stop' | 'restart' | 'redeploy';+type ContainerActionKind = 'start' | 'stop' | 'restart' | 'pause' | 'unpause' | 'redeploy';type ContainerActionConfig = TableActionConfig<ActionStatus>;type BulkActionConfig = TableBulkActionConfig<keyof BulkLoadingState>;-const containerActionConfigs: Record<Exclude<ContainerActionKind, 'start' | 'stop' | 'restart'>, ContainerActionConfig> = {+const containerActionConfigs: Record<+ Exclude<ContainerActionKind, 'start' | 'stop' | 'restart' | 'pause' | 'unpause'>,+ ContainerActionConfig+> = {redeploy: {status: 'redeploying',run: (id) => containerService.redeployContainer(id),@@ -54,7 +57,7 @@ export function createContainerActions({};async function performContainerAction(action: ContainerActionKind, id: string) {- if (action === 'start' || action === 'stop' || action === 'restart') {+ if (action === 'start' || action === 'stop' || action === 'restart' || action === 'pause' || action === 'unpause') {await runContainerLifecycleAction({action,containerId: id,diff --git a/frontend/src/routes/(app)/containers/container-table.helpers.ts b/frontend/src/routes/(app)/containers/container-table.helpers.tsindex e550c4c2e..efe395a3b 100644--- a/frontend/src/routes/(app)/containers/container-table.helpers.ts+++ b/frontend/src/routes/(app)/containers/container-table.helpers.ts@@ -1,7 +1,17 @@import { m } from '$lib/paraglide/messages';import type { ContainerSummaryDto } from '$lib/types/docker';-export type ActionStatus = 'starting' | 'stopping' | 'restarting' | 'updating' | 'removing' | 'redeploying' | '';+export type ActionStatus =+ | 'starting'+ | 'stopping'+ | 'restarting'+ | 'pausing'+ | 'unpausing'+ | 'killing'+ | 'updating'+ | 'removing'+ | 'redeploying'+ | '';export type StateBadgeVariant = 'green' | 'red' | 'amber';export function parseImageRef(imageRef: string): { repo: string; tag: string } {@@ -31,6 +41,9 @@ const actionStatusMessages: Record<ActionStatus, () => string> = {starting: () => m.common_action_starting(),stopping: () => m.common_action_stopping(),restarting: () => m.common_action_restarting(),+ pausing: () => m.common_action_pausing(),+ unpausing: () => m.common_action_unpausing(),+ killing: () => m.common_action_killing(),redeploying: () => m.common_action_redeploying(),updating: () => m.common_action_updating(),removing: () => m.common_action_removing(),diff --git a/frontend/src/routes/(app)/containers/container-table.svelte b/frontend/src/routes/(app)/containers/container-table.svelteindex 44fb49748..23f908046 100644--- a/frontend/src/routes/(app)/containers/container-table.svelte+++ b/frontend/src/routes/(app)/containers/container-table.svelte@@ -53,8 +53,12 @@ProjectsIcon,InspectIcon,UpdateIcon,- RedeployIcon+ RedeployIcon,+ PauseIcon,+ PlayIcon,+ ZapIcon} from '$lib/icons';+ import KillContainerDialog from './components/kill-container-dialog.svelte';type FieldVisibility = Record<string, boolean>;@@ -180,6 +184,16 @@const currentEnvId = $derived(environmentStore.selected?.id || '0');const canUpdateContainers = $derived(hasPermission('containers:autoupdate', currentEnvId));+ const canKillContainers = $derived(hasPermission('containers:kill', currentEnvId));+ const canPauseContainers = $derived(hasPermission('containers:pause', currentEnvId));++ // The dialog is mounted only while a row is targeted, so it gets fresh state on+ // every open; clearing the target unmounts it.+ let killTarget = $state<ContainerSummaryDto | null>(null);++ function openKillDialog(container: ContainerSummaryDto) {+ killTarget = container;+ }onMount(() => {collapsedGroupsState = new PersistedState<Record<string, boolean>>('container-groups-collapsed', {});@@ -631,7 +645,21 @@{/if}</DropdownMenu.Item>{/if}- {#if item.state !== 'running'}+ {#if item.state === 'paused'}+ {#if canPauseContainers}+ <DropdownMenu.Item+ onclick={() => performContainerAction('unpause', item.id)}+ disabled={status === 'unpausing' || isAnyLoading}+ >+ {#if status === 'unpausing'}+ <Spinner class="size-4" />+ {:else}+ <PlayIcon class="size-4" />+ {/if}+ {m.common_unpause()}+ </DropdownMenu.Item>+ {/if}+ {:else if item.state !== 'running'}<DropdownMenu.Itemonclick={() => performContainerAction('start', item.id)}disabled={status === 'starting' || isAnyLoading}@@ -667,6 +695,27 @@{/if}{m.common_restart()}</DropdownMenu.Item>++ {#if canPauseContainers}+ <DropdownMenu.Item+ onclick={() => performContainerAction('pause', item.id)}+ disabled={status === 'pausing' || isAnyLoading}+ >+ {#if status === 'pausing'}+ <Spinner class="size-4" />+ {:else}+ <PauseIcon class="size-4" />+ {/if}+ {m.common_pause()}+ </DropdownMenu.Item>+ {/if}+ {/if}++ {#if (item.state === 'running' || item.state === 'paused') && canKillContainers}+ <DropdownMenu.Item onclick={() => openKillDialog(item)} disabled={isAnyLoading}>+ <ZapIcon class="size-4" />+ {m.common_kill()}+ </DropdownMenu.Item>{/if}{#if item.redeployDisabled}@@ -743,3 +792,14 @@{m.containers_hide_unexposed_ports()}</DropdownMenu.CheckboxItem>{/snippet}++{#if killTarget}+ <KillContainerDialog+ containerId={killTarget.id}+ containerName={getContainerDisplayName(killTarget)}+ onClose={() => (killTarget = null)}+ onComplete={async () => {+ await refreshContainers(requestOptions);+ }}+ />+{/if}diff --git a/frontend/src/routes/(app)/projects/components/ProjectContainersTable.svelte b/frontend/src/routes/(app)/projects/components/ProjectContainersTable.svelteindex 8780db89c..ee11b2e2b 100644--- a/frontend/src/routes/(app)/projects/components/ProjectContainersTable.svelte+++ b/frontend/src/routes/(app)/projects/components/ProjectContainersTable.svelte@@ -58,7 +58,7 @@);// Track action status per container ID- type ActionStatus = 'starting' | 'stopping' | 'restarting' | 'removing' | '';+ type ActionStatus = 'starting' | 'stopping' | 'restarting' | 'pausing' | 'unpausing' | 'removing' | '';let actionStatus = $state<Record<string, ActionStatus>>({});let isBulkLoading = $state({diff --git a/frontend/src/routes/(app)/volumes/[volumeName]/+page.ts b/frontend/src/routes/(app)/volumes/[volumeName]/+page.tsindex c6552a066..2384503e4 100644--- a/frontend/src/routes/(app)/volumes/[volumeName]/+page.ts+++ b/frontend/src/routes/(app)/volumes/[volumeName]/+page.ts@@ -26,11 +26,8 @@ export const load: PageLoad = async ({ params, parent }) => {queryKey: queryKeys.containers.detail(envId, id),queryFn: () => containerService.getContainerForEnvironment(envId, id)});- const idVal = (c?.id || c?.Id || id) as string;- const nameVal = (c?.name ||- c?.Name ||- (c?.Names && c?.Names[0]?.replace?.(/^\//, '')) ||- idVal?.substring(0, 12)) as string;+ const idVal = c?.id || id;+ const nameVal = c?.name || idVal.substring(0, 12);return { id: idVal, name: nameVal };} catch {return { id, name: id.substring(0, 12) };