AI编程助手
AI免费问答

Docker golang + ffmpeg 执行命令失败

王林   2024-02-06 11:45   1233浏览 转载

docker golang + ffmpeg 执行命令失败

问题内容

您好,我正在使用以下 docker 映像:

from golang:alpine3.18

使用 ffmpeg:(可能在这里我遗漏了一些东西)

run apk add --no-cache ffmpeg

但是当尝试执行以下操作时:

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))
}

我收到此错误:

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

正确答案


Alpine docker 镜像默认没有安装 bash。它使用 Ash shell 来代替

答案已经在这里 Docker:如何将 bash 与基于 Alpine 的 docker 镜像一起使用?

golang免费学习笔记(深入):立即学习
在学习笔记中,你将探索golang的核心概念和高级技巧!

声明:本文转载于:stackoverflow,如有侵犯,请联系admin@php.cn删除