简体   繁体   中英

Docker not able to find/run binary

I have what I believe is a pretty simple setup.

I build a binary file outside of docker and then try to add it using this Dockerfile

FROM alpine

COPY apps/dist/apps /bin/

RUN chmod +x /bin/apps

RUN ls -al /bin | grep apps

CMD /bin/apps

And I think this should work. The binary on its own seems to work on my host machine and I don't understand why it wouldn't on the docker image.

Anyways, the output I get is this:

 docker build -t apps -f app.Dockerfile . && docker run apps
Sending build context to Docker daemon  287.5MB
Step 1/5 : alpine
 ---> d05cf6536f67
Step 2/5 : COPY apps/dist/apps /bin/
 ---> Using cache
 ---> c54d6d57154e
Step 3/5 : RUN chmod +x /bin/apps
 ---> Using cache
 ---> aa7e6adb0981
Step 4/5 : RUN ls -al /bin | grep apps
 ---> Running in 868c5e235d68
-rwxr-xr-x    1 root     root      68395166 Dec 20 13:35 apps
Removing intermediate container 868c5e235d68
 ---> f052c06269b0
Step 5/5 : CMD /bin/apps
 ---> Running in 056fd02733e1
Removing intermediate container 056fd02733e1
 ---> 331600154cbe
Successfully built 331600154cbe
Successfully tagged apps:latest
/bin/sh: /bin/apps: not found

does this make sense, and am I just missing something obvious?

Your binary likely has dynamic links to libraries that don't exist inside the image filesystem. You can check those dynamic links with the ldd apps/dist/apps command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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