第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么找不到二進(jìn)制 dlv - 沒(méi)有這樣的文件或目錄

為什么找不到二進(jìn)制 dlv - 沒(méi)有這樣的文件或目錄

Go
LEATH 2023-03-07 15:25:25
我有一個(gè)工作正常的 docker 文件。但是要遠(yuǎn)程調(diào)試它,我讀到我需要在它上面安裝dlv然后我需要運(yùn)行 dlv 并傳遞我正在嘗試調(diào)試的應(yīng)用程序的參數(shù)。因此,在其上安裝 dlv 并嘗試運(yùn)行它之后。我得到錯(cuò)誤exec /dlv: no such file or directory這是泊塢窗文件    FROM golang:1.18-alpine AS builder# Build Delve for debuggingRUN go install github.com/go-delve/delve/cmd/dlv@latest# Create and change to the app directory.WORKDIR /appENV 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-slimEXPOSE 8000 40000RUN 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 parameterCMD ["/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/app/fooapp"]以上結(jié)果exec /dlv: no such file or directory我不確定為什么會(huì)這樣。作為 docker 的新手,我嘗試了不同的方法來(lái)調(diào)試它。我試著用它dive來(lái)檢查圖像是否dlv在路徑中/dlv,它確實(shí)如此。我還附上了它的圖片
查看完整描述

2 回答

?
一只萌萌小番薯

TA貢獻(xiàn)1795條經(jīng)驗(yàn) 獲得超7個(gè)贊

您構(gòu)建了dlv基于alpine- 的發(fā)行版。dlv可執(zhí)行文件鏈接到libc.musl:


# ldd dlv 

        linux-vdso.so.1 (0x00007ffcd251d000)

        libc.musl-x86_64.so.1 => not found

但是后來(lái)你切換到glibc基于圖像debian:buster-slim。該圖像沒(méi)有所需的庫(kù)。


# find / -name libc.musl*                                        

<nothing found>

這就是您無(wú)法執(zhí)行的原因dlv- 動(dòng)態(tài)鏈接器無(wú)法找到正確的庫(kù)。


您需要構(gòu)建glibc基于 - 的 docker。例如,替換第一行


FROM golang:bullseye AS builder

順便提一句。構(gòu)建后,您需要以特權(quán)模式運(yùn)行容器


$ docker build . -t try-dlv

...

$ docker run --privileged --rm try-dlv

API server listening at: [::]:40000

2022-10-30T10:51:02Z warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)

在非特權(quán)容器中dlv不允許產(chǎn)生子進(jìn)程。


$ docker run --rm try-dlv

API server listening at: [::]:40000

2022-10-30T10:55:46Z warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)

could not launch process: fork/exec /app/fooapp: operation not permitted

真正最小的圖像


你用來(lái)debian:buster-slim最小化圖像,它的大小是 80 MB。但是如果你需要一個(gè)非常小的圖像,使用busybox,它只有 4.86 MB 的開(kāi)銷。


FROM golang:bullseye 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 -o fooapp .


# Download certificates

RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \

    ca-certificates 


# Use the official Debian slim image for a lean production container.

FROM busybox:glibc


EXPOSE 8000 40000


# Copy the binary to the production image from the builder stage.

COPY --from=builder /app/fooapp /app/fooapp 

# COPY --from=builder /app/ /app


COPY --from=builder /go/bin/dlv /dlv


COPY --from=builder /etc/ssl /etc/ssl


# Run dlv as pass fooapp as parameter

CMD ["/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/app/fooapp"]

# ENTRYPOINT ["/bin/sh"]

圖像大小為 25 MB,其中 18 MB 來(lái)自應(yīng)用程序dlv,2 MB 來(lái)自Hello World應(yīng)用程序。


在選擇圖像時(shí),應(yīng)注意具有相同風(fēng)格的libc. golang:bullseye針對(duì)glibc. 因此,最小圖像必須glibc基于。


但是,如果您想要更舒適一些,請(qǐng)使用已安裝的alpine軟件包gcompat。與busybox.


FROM golang:bullseye 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


# Copy local code to the container image.

COPY . ./


# Retrieve application dependencies.

RUN go mod tidy


# Build the binary.

RUN go build -o fooapp .


# Use alpine lean production container.

# FROM busybox:glibc

FROM alpine:latest


# gcompat is the package to glibc-based apps

# ca-certificates contains trusted TLS CA certs

# bash is just for the comfort, I hate /bin/sh

RUN apk add gcompat ca-certificates bash


EXPOSE 8000 40000


# Copy the binary to the production image from the builder stage.

COPY --from=builder /app/fooapp /app/fooapp 

# COPY --from=builder /app/ /app


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"]

# ENTRYPOINT ["/bin/bash"]


查看完整回答
反對(duì) 回復(fù) 2023-03-07
?
開(kāi)心每一天1111

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超13個(gè)贊

長(zhǎng)話短說(shuō)

運(yùn)行apt-get install musl,然后/dlv應(yīng)該按預(yù)期工作。

解釋

按著這些次序:

  1. docker run -it <image-name> sh

  2. apt-get install file

  3. file /dlv

然后你可以看到如下輸出:

/dlv: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, Go BuildID=xV8RHgfpp-zlDlpElKQb/DOLzpvO_A6CJb7sj1Nxf/aCHlNjW4ruS1RXQUbuCC/JgrF83mgm55ntjRnBpHH, not stripped

令人困惑no such file or directory(有關(guān)相關(guān)討論,請(qǐng)參閱此問(wèn)題)是由 missing 引起的/lib/ld-musl-x86_64.so.1。

因此,解決方案是musl按照其文檔安裝庫(kù)。

我的回答是受這個(gè)答案的啟發(fā)。


查看完整回答
反對(duì) 回復(fù) 2023-03-07
  • 2 回答
  • 0 關(guān)注
  • 269 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)