当前位置 博文首页 > yunweigo的博客:sh: ./xxx: not found
FROM golang:1.16.5 as builder
LABEL maintainer=YunweiGo
WORKDIR /app
COPY . .
RUN go env -w GO111MODULE=on; \
go env -w GOPROXY=https://goproxy.cn,direct
RUN go build -o hello .
FROM alpine:latest
WORKDIR /app
COPY --from=builder /app/hello /app
ENTRYPOINT ["./hello"]
构建镜像:
docker build -t hello .
docker run hello
>> sh: ./hello: not found #输出如下错误
重新编译,进入容器进行调试
/app # ./hello
>> sh: ./hello: not found
/app # ldd hello
/lib64/ld-linux-x86-64.so.2 (0x55a0a1807000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x55a0a1807000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x55a0a1807000)
/app # ls /lib64/ld-linux-x86-64.so.2
/lib64/ld-linux-x86-64.so.2 No such file or directory
我们将文件创建出来
mkdir /lib64
ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
重新执行正常运行
./hello
cs