I am trying to understand something inside dockerd
using dlv
debugger. Unfortunately, every time I am trying to do that I am facing errors. I can't do dlv exec
nor dlv attach
.
The following diff shows some changes I applied to docker/docker
to make sure that some go optimizations are avoided and debugging is possible:
diff --git i/hack/make/.binary w/hack/make/.binary
index d56e3f3..e6835fa 100644
--- i/hack/make/.binary
+++ w/hack/make/.binary
@@ -84,6 +84,7 @@ hash_files() {
go build \
-o "$DEST/$BINARY_FULLNAME" \
"${BUILDFLAGS[@]}" \
+ -gcflags="all=-N -l" \
-ldflags "
$LDFLAGS
$LDFLAGS_STATIC_DOCKER
I also modified dockerd-rootless.sh
to make sure I don't use plain exec
but dlv exec dockerd -- $@
. Unfortunately every time I get the following error:
Could not create config directory: mkdir /root/.config: permission denied.could not launch process: could not get .debug_frame section: could not find .debug_frame section
The same error happens when I try to dlv attach docker-pid
:
could not attach to pid 228089: could not get .debug_frame section: could not find .debug_frame section
Does anyone have an idea what could be causing it?
INFO:
uname -a
Linux host 5.6.8-200.fc31.x86_64 #1 SMP Wed Apr 29 19:10:01 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
go version
go version go1.13.10 linux/amd64
dlv version
Delve Debugger
Version: 1.4.0
Build: $Id: 67422e6f7148fa1efa0eac1423ab5594b223d93b $
docker version
Client: Docker Engine - Community
Version: 19.03.8
API version: 1.40
Go version: go1.12.17
Git commit: afacb8b7f0
Built: Wed Mar 11 01:27:05 2020
OS/Arch: linux/amd64
Experimental: false
So, this was due to LDFLAGS
and the presence of -w
flag used while executing go build
.