简体   繁体   English

sh 无法运行可执行文件

[英]sh can't run executable

I tried to run a executable inside a docker container of alpine:我试图在 alpine 的 docker 容器中运行可执行文件:

/usr/src/server # ls -l
total 57472
-rw-r--r--    1 root     root           166 Dec 29 12:22 Dockerfile
-rwxr-xr-x    1 root     root      58844530 Dec 29 12:35 server
/usr/src/server # ./server
/bin/sh: ./server: not found

It gives me the file not found error when trying to run the container, what am I missing?尝试运行容器时,它给了我file not found的错误,我错过了什么?

Dockerfile Dockerfile

FROM alpine:3.12.3

# Create server directory
WORKDIR /usr/src/server

# Bundle server Source
COPY . .

# Expose Port and Start Server
EXPOSE 3000
CMD [ "./server" ]

The build Dockerfile (uses buildkit)构建 Dockerfile(使用 buildkit)

FROM node:14 AS build-stage

# Create server directory
WORKDIR /usr/src/server 

# Install Nexe
RUN npm i nexe@3.3.7 -g

# Install Server Dependencies
COPY package*.json ./
RUN npm install --only=production

# Bundle server Source
COPY . .

# Build
RUN nexe app.js -r config/db.js -r config/email.js -r config/passport.js -r config/config.env \
                -r middleware/auth.js \
                -r models/Option.js -r models/Token.js -r models/User.js -r models/Votacao.js -r models/Voto.js \
                -r routes/auth.js -r routes/votacao.js \
                -t linux-x64-12.14.1 \
                -o server

# Copy to Build
FROM scratch AS export-stage
COPY --from=build-stage /usr/src/server/server /server

The nexe stage is a mess, I'm still porting to webpack... nexe 阶段一团糟,我仍在移植到 webpack ......

You are right, ldd was giving me some errors:你是对的,ldd 给了我一些错误:

Error loading shared library libstdc++.so.6: No such file or directory (needed by server)加载共享库 libstdc++.so.6 时出错:没有这样的文件或目录(服务器需要)

Error loading shared library libgcc_s.so.1: No such file or directory (needed by server)加载共享库 libgcc_s.so.1 时出错:没有这样的文件或目录(服务器需要)

Using debian solved them.使用 debian 解决了这些问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM