Search code examples
dockergoffmpeg

Docker golang + ffmpeg Failed to execute command


Hi I am using the following docker image:

FROM golang:alpine3.18

With ffmpeg: (probably here I am missing something)

RUN apk add --no-cache ffmpeg

However when trying to execute the following:

cmd := "ffmpeg -i Untitled.mp4 -vf \"fps=5,scale=320:-1:flags=lanczos\" -c:v pam -f image2pipe - | convert -delay 5 - -loop 0 -layers optimize test.gif"
_, err := exec.Command("bash", "-c", cmd).Output()
if err != nil {
    fmt.Println(fmt.Sprintf("Failed to execute command: %s", err))
}

I get this error:

 Failed to execute command: exec: "bash": executable file not found in $PATH

Solution

  • Alpine docker image doesn't have bash installed by default. It uses the Ash shell instead

    The answer is already here Docker: How to use bash with an Alpine based docker image?