moby/moby
Debugging
Common debugging tools for dockerd and the test suites.
Daemon logs
dockerd logs to stderr by default; under systemd they go to journald. Set verbosity with:
dockerd --log-level=debug
# or in /etc/docker/daemon.json
{ "log-level": "debug" }The log facade is github.com/containerd/log. Every backend method receives a context.Context, and log.G(ctx) returns a logger with request-scoped fields. Routers add module=api, method, and request-url fields automatically (see the handler in daemon/server/server.go).
Stack dumps
The daemon installs a SIGUSR1 handler on Unix that dumps all goroutines to the log. See daemon/debugtrap_unix.go and daemon/debugtrap_windows.go.
kill -SIGUSR1 $(pidof dockerd)pprof
The daemon exposes net/http/pprof on its debug endpoint when the --debug flag (or "debug": true in the config) is set. Routes are registered by daemon/server/router/debug/. Typical use:
curl --unix-socket /var/run/docker.sock http://./debug/pprof/goroutine?debug=2Tracing
OpenTelemetry HTTP tracing is enabled in daemon/server/server.go via otelhttp.NewHandler. Spans are emitted for each Engine API call. The CI sets up an OTel collector via otelcol-ci-config.yml for failing tests.
Common failure patterns
Daemon won't start
- Existing containerd not reachable: containerd path/address is configured under
[plugins."io.containerd.grpc.v1.cri"]-style options. Checkcontainerd-addressin the daemon config. - Socket permission:
dockerdneeds to listen on/var/run/docker.sock. Thedockergroup owns it; group membership matters. - Storage driver init: graphdriver init logs come from
daemon/graphdriver/. On overlay2, mount errors typically indicate kernel mismatches orxfswithoutd_type=true.
Container start hangs
- Likely a libnetwork issue. Check
daemon/libnetwork/sandbox.goand the bridge or overlay driver logs. - The
docker-proxyuserland helper may fail if the host port is in use; the bridge driver logsport allocation.
Pull/push errors
- Live in
daemon/internal/distribution/(legacy store) or the containerd resolver path underdaemon/containerd/. Look forpull_v2.go/push_v2.golog entries.
Builder errors
- Classic builder: logs prefixed by the parser stage; entry points under
daemon/builder/dockerfile/. - BuildKit: log fields include
vertexandname. The integration is indaemon/internal/builder-next/.
Running a debugger
make BIND_DIR=. shell mounts the source tree into the dev container. Inside, dlv attach to the running daemon, or use DELVE_PORT from the Makefile to expose the Delve port to the host.
Logs from tests
Failed integration tests dump the daemon log into bundles/test-integration/. The journal is preserved per-suite. TESTDEBUG=1 make test-integration retains the bundles even on success.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.