Delve在Docker容器中无法安装。

huangapple go评论81阅读模式
英文:

Delve not installing in docker container

问题

我正在尝试在我的 Docker 容器中安装 delve,以便调试 Go 应用程序。

在我的 Dockerfile 中,我添加了以下内容:

RUN go get github.com/go-delve/delve/cmd/dlv

但是当我进入 Docker 容器并运行 dlv 时,它显示:

bash: dlv: command not found

我尝试在容器中直接运行 go get github.com/go-delve/delve/cmd/dlv 来手动安装它。运行完成后没有输出。但是我仍然得到相同的 "command not found" 错误。

看起来 delve 并没有被安装。这是容器内的环境变量和 Go 二进制文件目录:

root@5d8aef1f6721:/my/project# printenv | grep GO
GOFLAGS=-mod=vendor
GOLANG_VERSION=1.19.1
GOROOT=/usr/local/go
GOPATH=/go
root@5d8aef1f6721:/my/project# printenv | grep PATH
PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GOPATH=/go
root@5d8aef1f6721:/my/project# ls -la /go/bin
total 23540
drwxrwxrwx 1 root root     4096 Sep 20 10:29 .
drwxrwxrwx 1 root root     4096 Sep 20 10:28 ..
-rwxr-xr-x 1 root root 24085739 Sep 20 10:29 saml
root@5d8aef1f6721:/my/project# ls -la /usr/local/go/bin
total 17456
drwxr-xr-x  2 root root     4096 Aug 31 17:40 .
drwxr-xr-x 10 root root     4096 Aug 31 17:40 ..
-rwxr-xr-x  1 root root 14520630 Aug 31 17:40 go
-rwxr-xr-x  1 root root  3340906 Aug 31 17:40 gofmt

我对为什么它没有安装成功感到困惑... 有什么想法吗?

英文:

I'm trying to get delve installed in my docker container for debugging Go applications.

In my Dockerfile I put:

RUN go get github.com/go-delve/delve/cmd/dlv

But when I enter the docker container and run dlv it says

bash: dlv: command not found

I tried manually installing it by running go get github.com/go-delve/delve/cmd/dlv directly in the container. It finishes with no output. But I still get the same "command not found" error

It doesn't look like it installed delve at all. Here are my environment variables and Go bin directories inside the container:

root@5d8aef1f6721:/my/project# printenv | grep GO
GOFLAGS=-mod=vendor
GOLANG_VERSION=1.19.1
GOROOT=/usr/local/go
GOPATH=/go
root@5d8aef1f6721:/my/project# printenv | grep PATH
PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GOPATH=/go
root@5d8aef1f6721:/my/project# ls -la /go/bin
total 23540
drwxrwxrwx 1 root root     4096 Sep 20 10:29 .
drwxrwxrwx 1 root root     4096 Sep 20 10:28 ..
-rwxr-xr-x 1 root root 24085739 Sep 20 10:29 saml
root@5d8aef1f6721:/my/project# ls -la /usr/local/go/bin
total 17456
drwxr-xr-x  2 root root     4096 Aug 31 17:40 .
drwxr-xr-x 10 root root     4096 Aug 31 17:40 ..
-rwxr-xr-x  1 root root 14520630 Aug 31 17:40 go
-rwxr-xr-x  1 root root  3340906 Aug 31 17:40 gofmt

I'm stumped as to why it's not installing... Any idea?

答案1

得分: 5

go install github.com/go-delve/delve/cmd/dlv@latest。更多信息请参考这里https://stackoverflow.com/a/24878851/4638604。

英文:

go install github.com/go-delve/delve/cmd/dlv@latest. More here https://stackoverflow.com/a/24878851/4638604

huangapple
  • 本文由 发表于 2022年9月20日 18:41:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/73785388.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定