Home  >  Article  >  Backend Development  >  Docker golang + ffmpeg fails to execute command

Docker golang + ffmpeg fails to execute command

王林
王林forward
2024-02-06 11:45:131112browse

Docker golang + ffmpeg 执行命令失败

Question content

Hello, I am using the following docker image:

from golang:alpine3.18

Using ffmpeg: (Maybe I'm missing something here)

run apk add --no-cache ffmpeg

But when trying to do 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

Correct answer


The Alpine docker image does not have bash installed by default. It uses Ash shell instead

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

The above is the detailed content of Docker golang + ffmpeg fails to execute command. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete