{"record":{"id":"838e9053e71ffe5c","repo":"nektos/act","slug":"failed-to-connect-to-docker-daemon-w","errorCode":null,"errorMessage":"failed to connect to docker daemon: %w","messagePattern":"failed to connect to docker daemon: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/container/docker_run.go","lineNumber":236,"sourceCode":"func GetDockerClient(_ context.Context) (cli client.APIClient, err error) {\n\tdockerHost := os.Getenv(\"DOCKER_HOST\")\n\n\tif strings.HasPrefix(dockerHost, \"ssh://\") {\n\t\tvar helper *connhelper.ConnectionHelper\n\n\t\thelper, err = connhelper.GetConnectionHelper(dockerHost)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcli, err = client.New(\n\t\t\tclient.WithHost(helper.Host),\n\t\t\tclient.WithDialContext(helper.Dialer),\n\t\t)\n\t} else {\n\t\tcli, err = client.New(client.FromEnv)\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to connect to docker daemon: %w\", err)\n\t}\n\n\treturn cli, nil\n}\n\nfunc GetHostInfo(ctx context.Context) (info system.Info, err error) {\n\tvar cli client.APIClient\n\tcli, err = GetDockerClient(ctx)\n\tif err != nil {\n\t\treturn info, err\n\t}\n\tdefer cli.Close()\n\n\tresult, err := cli.Info(ctx, client.InfoOptions{})\n\tif err != nil {\n\t\treturn info, err\n\t}\n","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/nektos/act/blob/4f411281417e88660bea1c1a1749aa71ae0bd60f/pkg/container/docker_run.go#L218-L254","documentation":"GetDockerClient builds a Docker API client either from a ssh:// DOCKER_HOST (via connhelper) or from the environment (client.FromEnv). If client.New fails — malformed host URL, unsupported scheme, bad TLS config — the wrapped error 'failed to connect to docker daemon' is returned. Note it fires on client construction, not on an actual ping of the daemon.","triggerScenarios":"DOCKER_HOST set to an invalid or unsupported value (e.g. tcp://[::1, unknown scheme), DOCKER_TLS_VERIFY/DOCKER_CERT_PATH misconfigured, or ssh:// host where connhelper setup succeeded but client options are rejected.","commonSituations":"Broken DOCKER_HOST after switching between docker contexts, stale docker-machine/remote settings, missing client certificates, or a typo'd unix socket path. act fails at startup before any container work.","solutions":["Inspect DOCKER_HOST: valid forms are unix:///var/run/docker.sock, tcp://host:port, ssh://user@host, npipe://... (Windows)","docker context show / docker context ls to find the intended endpoint and align DOCKER_HOST","Unset DOCKER_HOST to use the local socket: env -u DOCKER_HOST act ...","For TLS endpoints, verify DOCKER_CERT_PATH contains ca.pem/cert.pem/key.pem matching DOCKER_TLS_VERIFY=1"],"exampleFix":"# before\nexport DOCKER_HOST=tcp://localhost  # missing port / wrong scheme\n\n# after\nexport DOCKER_HOST=unix:///var/run/docker.sock","handlingStrategy":"try-catch","validationCode":"# shell: validate the endpoint before running act\ncase \"$DOCKER_HOST\" in\n  unix:///*|tcp://*:*|ssh://*|npipe://*|\"\") : ;;\n  *) echo \"bad DOCKER_HOST: $DOCKER_HOST\" >&2; exit 1 ;;\nesac\ndocker version >/dev/null","typeGuard":null,"tryCatchPattern":"// Go: construct the client, then verify with a cheap call\ncli, err := container.GetDockerClient(ctx)\nif err != nil {\n    return fmt.Errorf(\"docker client setup failed (check DOCKER_HOST=%q): %w\", os.Getenv(\"DOCKER_HOST\"), err)\n}\ndefer cli.Close()\nif _, err := cli.Info(ctx, client.InfoOptions{}); err != nil { return err }","preventionTips":["Standardize DOCKER_HOST via docker context instead of ad-hoc exports","In CI, assert docker version as the first step before act","Keep TLS env vars (DOCKER_TLS_VERIFY, DOCKER_CERT_PATH) paired and consistent"],"tags":["docker","daemon-connection","docker-host","configuration"],"backgroundTag":null,"analyzedSha":"4f411281417e88660bea1c1a1749aa71ae0bd60f","analyzedAt":"2026-08-15T09:19:46.307Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}