我使用
docker build
和 docker run
几个星期都很好。我想放入容器中的可执行文件也运行良好。
突然我得到这个错误,我不明白:
root@DESKTOP-EVLULFV:/home/simple/simple# docker run -i -p 8080:8080 --name simple --platform linux/amd64 quarkus/simple
./application: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
libz.so.1 位于 /usr/lib/x86_64-linux-gnu 中,我将该文件夹放在我的路径中。
root@DESKTOP-EVLULFV:/usr/lib/x86_64-linux-gnu$ ls libz.so.1
libz.so.1
我成功构建了我的 docker 镜像:
docker build -f Dockerfile.native -t quarkus/simple .
我想检查容器,但它没有运行。
如何告诉 Docker libz.so.1 在哪里?
运行 ldd 来验证链接是否正确
root@DESKTOP-EVLULFV:/home/simple/simple# ldd -v /usr/lib/x86_64-linux-gpu/libz.so.1
No such file or directory
没关系,修复它
我的 docker 文件有错误。这是有效的:
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
#
# Before building the container image run:
#
# ./mvnw package -Dnative
#
# Then, build the image with:
#
# docker build -f Dockerfile.native -t quarkus/simple .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/simple
#
###
FROM ubuntu:20.04
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work
COPY --chown=1001:root target/*-runner /work/application
EXPOSE 8080
USER 1001
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]