posit labs
posit labs

Reputation: 9471

Copy ffmpeg bins in multistage docker build

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

Upvotes: 5

Views: 5429

Answers (3)

posit labs
posit labs

Reputation: 9471

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>

Upvotes: 3

Torkashvand
Torkashvand

Reputation: 416

It seems that this issue opened here. And there is some solution for it like this one and this one.

Upvotes: 1

Mattias Wadman
Mattias Wadman

Reputation: 11425

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/

Upvotes: 7

Related Questions