{"id":"9206ab957ebf934b","repo":"docker/cli","slug":"cannot-attach-to-a-paused-container-unpause-it-fi","errorCode":null,"errorMessage":"cannot attach to a paused container, unpause it first","messagePattern":"cannot attach to a paused container, unpause it first","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/attach.go","lineNumber":34,"sourceCode":")\n\n// AttachOptions group options for `attach` command\ntype AttachOptions struct {\n\tNoStdin    bool\n\tProxy      bool\n\tDetachKeys string\n}\n\nfunc inspectContainerAndCheckState(ctx context.Context, apiClient client.APIClient, args string) (*container.InspectResponse, error) {\n\tc, err := apiClient.ContainerInspect(ctx, args, client.ContainerInspectOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !c.Container.State.Running {\n\t\treturn nil, errors.New(\"cannot attach to a stopped container, start it first\")\n\t}\n\tif c.Container.State.Paused {\n\t\treturn nil, errors.New(\"cannot attach to a paused container, unpause it first\")\n\t}\n\tif c.Container.State.Restarting {\n\t\treturn nil, errors.New(\"cannot attach to a restarting container, wait until it is running\")\n\t}\n\n\treturn &c.Container, nil\n}\n\n// newAttachCommand creates a new cobra.Command for `docker attach`\nfunc newAttachCommand(dockerCLI command.Cli) *cobra.Command {\n\tvar opts AttachOptions\n\n\tcmd := &cobra.Command{\n\t\tUse:   \"attach [OPTIONS] CONTAINER\",\n\t\tShort: \"Attach local standard input, output, and error streams to a running container\",\n\t\tArgs:  cli.ExactArgs(1),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tcontainerID := args[0]","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/attach.go#L16-L52","documentation":"Raised by inspectContainerAndCheckState in cli/command/container/attach.go when the target container's State.Paused is true. A paused container has all its processes frozen via the cgroup freezer, so an attached terminal would receive no output and its input would go nowhere; the CLI rejects the attach up front with instructions to unpause.","triggerScenarios":"`docker attach <container>` against a container previously paused with `docker pause` (or via an orchestrator/tool that pauses containers), where ContainerInspect returns State.Running == true and State.Paused == true.","commonSituations":"Containers paused by resource-management or checkpoint tooling and forgotten; someone else on a shared host ran `docker pause`; debugging sessions where pause was used to freeze state and the operator later tries to attach without unpausing — `docker ps` shows the container as '(Paused)' which is easy to miss.","solutions":["Unpause the container, then attach: `docker unpause <container> && docker attach <container>`.","Confirm the paused state first with `docker ps` (STATUS shows '(Paused)') or `docker inspect -f '{{.State.Paused}}' <container>`.","If the pause was intentional (e.g. freezing for a snapshot), finish that operation before attaching."],"exampleFix":"# before\ndocker attach myapp   # Error: cannot attach to a paused container\n# after\ndocker unpause myapp\ndocker attach myapp","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","container-lifecycle","attach","pause"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}