如何将ffmpeg命令安装到我的Docker容器中?

huangapple go评论170阅读模式
英文:

How to Install ffmpeg command into my docker

问题

我正在我的docker-compose.yml文件中进行如下操作:

  1. app:
  2. image: golang:1.14.3
  3. ports:
  4. - "8080:8080" ## 与主机共享API端口。
  5. depends_on:
  6. - broker
  7. - ffmpeg
  8. volumes:
  9. - .:/go/src/go-intelligent-monitoring-system
  10. - /home/:/home/
  11. working_dir: /go/src/go-intelligent-monitoring-system
  12. command: apt-get install ffmpeg ########-------<<<<---------#################
  13. command: go run main.go

但是当我在我的代码中使用它时,出现了以下错误:
---> "exec: "ffmpeg": 在$PATH中找不到可执行文件"

英文:

Im am doing that in my docker-compose.yml:

  1. app:
  2. image: golang:1.14.3
  3. ports:
  4. - &quot;8080:8080&quot; ## Share API port with host machine.
  5. depends_on:
  6. - broker
  7. - ffmpeg
  8. volumes:
  9. - .:/go/src/go-intelligent-monitoring-system
  10. - /home/:/home/
  11. working_dir: /go/src/go-intelligent-monitoring-system
  12. command: apt-get install ffmpeg ########-------&lt;&lt;&lt;&lt;&lt;&lt;---------#################
  13. command: go run main.go

But when I use it on my code, I have this error:
--> ""exec: &quot;ffmpeg&quot;: executable file not found in $PATH""

答案1

得分: 1

只有compose文件中的最后一个command会生效,所以你没有机会使用当前的compose文件安装ffmpeg。

作为替代,你应该在自定义的Dockerfile中安装ffmpeg,像下面这样,参考这里

  1. app:
  2. build: ./dir

将你自定义的Dockerfile放在上述的dir中,像下面这样:

Dockerfile:

  1. FROM golang:1.14.3
  2. 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:

  1. app:
  2. build: ./dir

Put you customized Dockerfile in above dir like next:

Dockerfile:

  1. FROM golang:1.14.3
  2. RUN apt-get update &amp;&amp; apt-get install ffmpeg -y

huangapple
  • 本文由 发表于 2021年5月27日 10:43:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/67714988.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定