问题
I'm trying to install ffmpeg via a multistage docker build
Here is the ffmpeg image that contains the ffmpeg binaries
FROM jrottenberg/ffmpeg
Here is the pm2 image that I need to run my web server
FROM keymetrics/pm2:8-alpine
I copy the bins into the current image, and I can see that ffmpeg, ffserver, and ffprobe all exist in /usr/local/bin.
COPY --from=0 /usr/local /usr/local
The copy command appears to succeed, since those files exist when I run the container interactively.
$# which ffmpeg
/usr/local/bin/ffmpeg
However, when I try running the bins, it says the command isn't found.
$# ffmpeg --version
/bin/sh: ffmpeg: not found
回答1:
I've had a similar issue and ended up building my own binaries with no dependencies using the alpine gcc toolchain that supports building "static" PIE binaries. The reason was that I wanted no dependencies, hardened build and also support ASLR.
https://hub.docker.com/r/mwader/static-ffmpeg/
回答2:
It makes sense that you need to use the same base image for compatibility reasons. I was using jrottenberg/ffmpeg
(which defaults to ubuntu). I should have been using jrottenberg/ffmpeg:3.3-alpine
since I'm using the alpine-based pm2 image.
Also, building ffmpeg depends on some shared libraries, so copying /usr/local wasn't enough to make it work. I'm sure there's a more graceful solution, but I ended up just copying the root dir, which did the trick.
FROM jrottenberg/ffmpeg:3.3-alpine
# copy ffmpeg bins
COPY --from=0 / /
FROM <extension of 3.3-alpine>
回答3:
It seems that this issue opened here. And there is some solution for it like this one and this one.
来源:https://stackoverflow.com/questions/51866631/copy-ffmpeg-bins-in-multistage-docker-build