{"record":{"id":"4277792b455bb452","repo":"nektos/act","slug":"failed-to-remove-image-s","errorCode":null,"errorMessage":"failed to remove image '%s'","messagePattern":"failed to remove image '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runner/action.go","lineNumber":283,"sourceCode":"\t\tcontextDir, fileName := path.Split(path.Join(subpath, action.Runs.Image))\n\n\t\tanyArchExists, err := container.ImageExistsLocally(ctx, image, \"any\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tcorrectArchExists, err := container.ImageExistsLocally(ctx, image, rc.Config.ContainerArchitecture)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif anyArchExists && !correctArchExists {\n\t\t\twasRemoved, err := container.RemoveImage(ctx, image, true, true)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif !wasRemoved {\n\t\t\t\treturn fmt.Errorf(\"failed to remove image '%s'\", image)\n\t\t\t}\n\t\t}\n\n\t\tif !correctArchExists || rc.Config.ForceRebuild {\n\t\t\tlogger.Debugf(\"image '%s' for architecture '%s' will be built from context '%s\", image, rc.Config.ContainerArchitecture, contextDir)\n\t\t\tvar buildContext io.ReadCloser\n\t\t\tif localAction {\n\t\t\t\tbuildContext, err = rc.JobContainer.GetContainerArchive(ctx, contextDir+\"/.\")\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tdefer buildContext.Close()\n\t\t\t} else if rc.Config.ActionCache != nil {\n\t\t\t\trstep := step.(*stepActionRemote)\n\t\t\t\tbuildContext, err = rc.Config.ActionCache.GetTarArchive(ctx, rstep.cacheDir, rstep.resolvedSha, contextDir)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/nektos/act/blob/4f411281417e88660bea1c1a1749aa71ae0bd60f/pkg/runner/action.go#L265-L301","documentation":"Thrown by execAsDocker in pkg/runner/action.go when a Docker action image exists locally only for a different architecture. act calls container.RemoveImage(ctx, image, true, true) to prune the wrong-arch image; RemoveImage returns (false, nil) when the Docker remove call reports the image was already gone (e.g. raced/untagged) but no hard error occurred, so act cannot proceed to rebuild the correct-architecture image from a clean state.","triggerScenarios":"Running an action whose image was previously pulled for another platform (e.g. linux/amd64 cached while running with --container-architecture linux/arm64); the existence check for the correct arch fails, the any-arch check succeeds, and RemoveImage returns wasRemoved=false because 'docker rmi -f' reported NoSuchImage or the image was removed concurrently by another process.","commonSituations":"Switching between hosts/emulation (Apple Silicon vs x86), using -P/--container-architecture flags, running multiple act instances sharing one Docker daemon, or a stale dangling image entry that Docker refuses to remove.","solutions":["Manually remove the conflicting image: docker rmi -f <image> (the image name is printed in the error), then re-run act.","Run 'docker image prune -f' to clear dangling/wrong-arch layers that Docker cannot remove by name.","Avoid mixing --container-architecture values against the same cached action images; clear ~/.cache/act or the action cache dir when switching architectures.","If it persists, inspect 'docker images -a | grep <image>' for duplicate/untagged entries and remove them by ID."],"exampleFix":"# before (workflow run fails)\nact -P ubuntu-latest=catthehacker/ubuntu-latest:act-latest  # after previously using arm64 image\n\n# after (shell)\ndocker rmi -f $(docker images -q <image-from-error>)\nact -P ubuntu-latest=catthehacker/ubuntu-latest:act-latest","handlingStrategy":"validation","validationCode":"docker images --format '{{.Repository}}:{{.Tag}} {{.ID}}' | grep '^<image-from-error>'\n# if the arch column mismatches (docker inspect -f '{{.Architecture}}' <id>), remove before running act:\ndocker rmi -f $(docker images -q <image>)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clear cached action images when switching --container-architecture values.","Do not share one Docker daemon between act runs using different platforms.","Periodically run docker image prune to remove dangling wrong-arch layers."],"tags":["docker","architecture","image-cache","act"],"backgroundTag":null,"analyzedSha":"4f411281417e88660bea1c1a1749aa71ae0bd60f","analyzedAt":"2026-08-15T09:19:46.307Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}