英文:
How to Install ffmpeg command into my docker
问题
我正在我的docker-compose.yml文件中进行如下操作:
app:
image: golang:1.14.3
ports:
- "8080:8080" ## 与主机共享API端口。
depends_on:
- broker
- ffmpeg
volumes:
- .:/go/src/go-intelligent-monitoring-system
- /home/:/home/
working_dir: /go/src/go-intelligent-monitoring-system
command: apt-get install ffmpeg ########-------<<<<---------#################
command: go run main.go
但是当我在我的代码中使用它时,出现了以下错误:
---> "exec: "ffmpeg": 在$PATH中找不到可执行文件"
英文:
Im am doing that in my docker-compose.yml:
app:
image: golang:1.14.3
ports:
- "8080:8080" ## Share API port with host machine.
depends_on:
- broker
- ffmpeg
volumes:
- .:/go/src/go-intelligent-monitoring-system
- /home/:/home/
working_dir: /go/src/go-intelligent-monitoring-system
command: apt-get install ffmpeg ########-------<<<<<<---------#################
command: go run main.go
But when I use it on my code, I have this error:
--> ""exec: "ffmpeg": executable file not found in $PATH""
答案1
得分: 1
只有compose文件中的最后一个command会生效,所以你没有机会使用当前的compose文件安装ffmpeg。
作为替代,你应该在自定义的Dockerfile中安装ffmpeg,像下面这样,参考这里:
app:
build: ./dir
将你自定义的Dockerfile放在上述的dir中,像下面这样:
Dockerfile:
FROM golang:1.14.3
RUN apt-get update && apt-get install ffmpeg -y
英文:
Only the last command in compose file will take effect, so you didn't have chance to install ffmpeg with your current compose file.
As a replacement, you should install ffmpeg in your customized dockerfile like next, refers to this:
app:
build: ./dir
Put you customized Dockerfile in above dir like next:
Dockerfile:
FROM golang:1.14.3
RUN apt-get update && apt-get install ffmpeg -y
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论