{"record":{"id":"22a29f5050973b5b","repo":"abiosoft/colima","slug":"error-reloading-systemd-daemon-w","errorCode":null,"errorMessage":"error reloading systemd daemon: %w","messagePattern":"error reloading systemd daemon: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/container/docker/daemon.go","lineNumber":123,"sourceCode":"func (d dockerRuntime) addHostGateway(conf map[string]any) error {\n\t// get host-gateway ip from the guest\n\tip, err := getHostGatewayIp(d, conf)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// set host-gateway ip as systemd service file\n\tcontent := fmt.Sprintf(systemdUnitFileContent, ip)\n\tif err := d.guest.Write(systemdUnitFilename, []byte(content)); err != nil {\n\t\treturn fmt.Errorf(\"error creating systemd unit file: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (d dockerRuntime) reloadAndRestartSystemdService() error {\n\tif err := d.systemctl.DaemonReload(); err != nil {\n\t\treturn fmt.Errorf(\"error reloading systemd daemon: %w\", err)\n\t}\n\tif err := d.systemctl.Restart(\"docker.service\"); err != nil {\n\t\treturn fmt.Errorf(\"error restarting docker: %w\", err)\n\t}\n\treturn nil\n}\n\nconst systemdUnitFilename = \"/etc/systemd/system/docker.service.d/docker.conf\"\nconst systemdUnitFileContent string = `\n[Service]\nLimitNOFILE=infinity\nExecStart=\nExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --host-gateway-ip=%s\n`\n","sourceCodeStart":105,"sourceCodeEnd":138,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/container/docker/daemon.go#L105-L138","documentation":"Colima runs 'systemctl daemon-reload' inside the guest VM after installing the docker.service drop-in, and the systemctl call returned an error. It means systemd in the guest did not accept the reload — typically because systemd is not PID 1, the D-Bus/systemd socket is unavailable, or the just-written unit drop-in is syntactically invalid.","triggerScenarios":"systemctl.DaemonReload() via the guest runner fails: systemd not running in the guest, guest SSH broken, malformed drop-in written in the previous step, or an image that uses a non-systemd init.","commonSituations":"Using a custom Lima image without systemd as init, guest VM in a half-booted state, drop-in file truncated by a full disk, or a docker version whose unit file semantics changed.","solutions":["Retry: 'colima stop && colima start'","Manually verify in guest: 'colima ssh -- sudo systemctl daemon-reload' and read the error output","Inspect the drop-in: 'colima ssh -- cat /etc/systemd/system/docker.service.d/docker.conf' for corruption","Recreate the VM if the guest init/systemd setup is broken: 'colima delete && colima start'"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure systemd is functional in the guest before provisioning\nif err := guest.Run(\"systemctl\", \"is-system-running\"); err != nil {\n    return fmt.Errorf(\"guest systemd not ready: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := d.reloadAndRestartSystemdService(); err != nil {\n    if strings.Contains(err.Error(), \"error reloading systemd daemon\") {\n        // daemon-reload is often retryable once the guest settles\n        time.Sleep(2 * time.Second)\n        return d.reloadAndRestartSystemdService()\n    }\n    return err\n}","preventionTips":["Use stock colima VM images (systemd as PID 1)","After guest package upgrades, do a full 'colima stop && colima start' so units settle","Never edit /etc/systemd/system/docker.service.d manually while colima manages it"],"tags":["systemd","docker","vm","provisioning"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}