我有一个工作正常的 docker 文件。但是要远程调试它,我读到我需要在它上面安装dlv然后我需要运行 dlv 并传递我正在尝试调试的应用程序的参数。因此,在其上安装 dlv 并尝试运行它之后。我得到错误
exec /dlv: no such file or directory
这是泊坞窗文件
FROM golang:1.18-alpine AS builder
# Build Delve for debugging
RUN go install github.com/go-delve/delve/cmd/dlv@latest
# Create and change to the app directory.
WORKDIR /app
ENV CGO_ENABLED=0
# Retrieve application dependencies.
COPY go.* ./
RUN go mod download
# Copy local code to the container image.
COPY . ./
# Build the binary.
RUN go build -gcflags="all=-N -l" -o fooapp
# Use the official Debian slim image for a lean production container.
FROM debian:buster-slim
EXPOSE 8000 40000
RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Copy the binary to the production image from the builder stage.
#COPY --from=builder /app/fooapp /app/fooapp #commented this out
COPY --from=builder /go/bin/dlv /dlv
# Run dlv as pass fooapp as parameter
CMD ["/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/app/fooapp"]
以上结果exec /dlv: no such file or directory
我不确定为什么会这样。作为 docker 的新手,我尝试了不同的方法来调试它。我试着用它dive来检查图像是否dlv在路径中/dlv,它确实如此。我还附上了它的图片
一只萌萌小番薯
开心每一天1111
相关分类