{"record":{"id":"49a4fca758fe071f","repo":"apache/beam","slug":"couldn-t-connect-to-docker-w","errorCode":null,"errorMessage":"couldn't connect to docker:%w","messagePattern":"couldn't connect to docker:%w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/runners/prism/internal/environments.go","lineNumber":174,"sourceCode":"\t// This goroutine blocks until the context is cancelled, signalling\n\t// that the pool runner should stop the worker.\n\t<-ctx.Done()\n\n\t// Previous context cancelled so we need a new one\n\t// for this request.\n\tpool.StopWorker(bgContext, &fnpb.StopWorkerRequest{\n\t\tWorkerId: wk.ID,\n\t})\n\twk.Stop()\n}\n\nfunc dockerEnvironment(ctx context.Context, logger *slog.Logger, dp *pipepb.DockerPayload, wk *worker.W, artifactEndpoint string) error {\n\tlogger = logger.With(\"worker_id\", wk.ID, \"image\", dp.GetContainerImage())\n\n\t// TODO consider preserving client?\n\tcli, err := dcli.New(dcli.FromEnv)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't connect to docker:%w\", err)\n\t}\n\n\t// TODO abstract mounting cloud specific auths better.\n\tconst gcloudCredsEnv = \"GOOGLE_APPLICATION_CREDENTIALS\"\n\tgcloudCredsFile, ok := os.LookupEnv(gcloudCredsEnv)\n\tvar mounts []mount.Mount\n\tvar envs []string\n\tif ok {\n\t\t_, err := os.Stat(gcloudCredsFile)\n\t\t// File exists\n\t\tif err == nil {\n\t\t\tdockerGcloudCredsFile := \"/docker_cred_file.json\"\n\t\t\tmounts = append(mounts, mount.Mount{\n\t\t\t\tType:   \"bind\",\n\t\t\t\tSource: gcloudCredsFile,\n\t\t\t\tTarget: dockerGcloudCredsFile,\n\t\t\t})\n\t\t\tcredEnv := fmt.Sprintf(\"%v=%v\", gcloudCredsEnv, dockerGcloudCredsFile)","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/prism/internal/environments.go#L156-L192","documentation":"dockerEnvironment initializes a Docker client from the local environment (dcli.FromEnv) to launch an SDK harness container. If the Docker client cannot be constructed or connected — because Docker is absent or misconfigured — the error is wrapped as \"couldn't connect to docker\".","triggerScenarios":"dcli.New(dcli.FromEnv) fails when DOCKER_HOST is malformed, the Docker socket is missing, or the docker daemon is not running.","commonSituations":"Running prism on a host without Docker installed, DOCKER_HOST pointing to a dead remote, or missing socket permissions (user not in docker group).","solutions":["Install/start Docker and confirm `docker ps` works for the prism process user","Fix DOCKER_HOST (e.g. unix:///var/run/docker.sock) in the prism environment","Add the running user to the docker group or adjust socket permissions","Use the process or external environment type instead of docker if no daemon is available"],"exampleFix":"// before\nDOCKER_HOST=tcp://localhost:2375 prism --job ...\n// after\ndocker system start  # or on linux: sudo systemctl start docker\nDOCKER_HOST=unix:///var/run/docker.sock prism --job ...","handlingStrategy":"validation","validationCode":"if err := exec.Command(\"docker\", \"info\").Run(); err != nil {\n  return fmt.Errorf(\"docker daemon not reachable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := job.Run(ctx); err != nil {\n  var derr *dockerConnectErr\n  if errors.As(err, &derr) { /* start daemon / fix DOCKER_HOST */ }\n}","preventionTips":["Health-check `docker ps` before launching prism","Pin DOCKER_HOST explicitly in CI environments"],"tags":["go","beam","prism-runner","docker","connection"],"backgroundTag":"connection-refused","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}