{"record":{"id":"762901f9dceafa7b","repo":"amir20/dozzle","slug":"failed-to-write-agent-address-file-w","errorCode":null,"errorMessage":"failed to write agent address file: %w","messagePattern":"failed to write agent address file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/support/cli/agent_command.go","lineNumber":160,"sourceCode":"\tif args.Mode != \"server\" {\n\t\treturn fmt.Errorf(\"agent command is only available in server mode\")\n\t}\n\tclient, err := docker.NewLocalClient(args.Hostname)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create docker client: %w\", err)\n\t}\n\tcerts, err := ReadCertificates(embeddedCerts, args.CertPath, args.KeyPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to read certificates: %w\", err)\n\t}\n\n\tlistener, err := net.Listen(\"tcp\", args.Agent.Addr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to listen: %w\", err)\n\t}\n\tconst agentAddrFile = \"/tmp/dozzle-agent.addr\"\n\tif err := os.WriteFile(agentAddrFile, []byte(args.Agent.Addr), 0644); err != nil {\n\t\treturn fmt.Errorf(\"failed to write agent address file: %w\", err)\n\t}\n\tgo StartEvent(args, \"\", client, \"agent\")\n\n\tctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)\n\tdefer stop()\n\n\t// Create shared client service (single ContainerStore for both agent server and notifications)\n\tclientService := docker_support.NewDockerClientService(client, args.Filter)\n\n\t// Create notification manager using the shared client service\n\tconst notificationConfigPath = \"./data/notifications.yml\"\n\tclients := []container_support.ClientService{clientService}\n\tnotificationManager := notification.NewManager(\n\t\tnotification.NewContainerLogListener(ctx, clients),\n\t\tnotification.NewContainerStatsListener(ctx, clients),\n\t\tnotification.NewContainerEventListener(ctx, clients),\n\t)\n","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/support/cli/agent_command.go#L142-L178","documentation":"Returned by AgentCmd.Run when os.WriteFile fails to persist the bound agent address to /tmp/dozzle-agent.addr. Other local processes use this file to discover the agent's endpoint, so failing to write it aborts startup.","triggerScenarios":"/tmp is not writable (read-only rootfs, hardened container, noexec/tmpfs with restricted perms); disk full; the path exists as a directory or is otherwise unwritable by the process user.","commonSituations":"Running the agent in a distroless/read-only container filesystem; running as a non-root user with a locked-down /tmp; disk-full conditions on small VMs.","solutions":["Ensure /tmp is writable by the agent's process user (`touch /tmp/test`).","Run the container with a writable tmpfs: `--tmpfs /tmp:rw,size=64m`.","Free disk space if the filesystem is full.","Do not mount /tmp read-only for the agent container.","Run the agent in a filesystem mode that permits writing temp files."],"exampleFix":"// before\ndocker run --read-only amir20/dozzle:latest agent\n// after\ndocker run --read-only --tmpfs /tmp:rw,size=64m amir20/dozzle:latest agent","handlingStrategy":"try-catch","validationCode":"[ -w /tmp ] || { echo '/tmp not writable'; exit 1; }","typeGuard":null,"tryCatchPattern":"if err := agentCmd.Run(args, embeddedCerts); err != nil {\n  if strings.Contains(err.Error(), \"failed to write agent address file\") {\n    log.Fatal().Err(err).Msg(\"make /tmp writable (e.g. docker --tmpfs /tmp:rw)\")\n  }\n}","preventionTips":["Mount a writable tmpfs at /tmp in read-only containers","Monitor disk space on hosts running agents","Do not set /tmp read-only for the agent","Run smoke tests with the same filesystem hardening as production"],"tags":["filesystem","tmp","agent"],"backgroundTag":"file-write-failed","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}