【问题标题】:Modifying golang Docker Container using the running shell使用正在运行的 shell 修改 golang Docker 容器
【发布时间】:2014-11-18 19:16:10
【问题描述】:

我正在使用 Docker 将我的网络服务部署到 Google Compute Engine,并按照此处给出的说明进行操作:https://blog.golang.org/docker

我想在 golang 容器中安装 ffmpeg,我的方法是访问 shell

docker run -t -i my-webservice /bin/bash

与 ubuntu:14.04 映像相反,我无法访问 bash shell。怎么可能?

我还找到了一个图像,其中 ffmpeg 已经配置和安装 (https://registry.hub.docker.com/u/cellofellow/ffmpeg/)。是否可以从 golang 容器访问容器,还是必须将 ffmpeg 安装到我自己的 docker 映像中?

【问题讨论】:

  • 你试过/bin/sh吗? Bash 在 Linux 上不是必须的。可能安装了其他 shell,可能是 dash。
  • 不幸的是,这也不起作用。我试过csh、tcsh、ksh、sh(假设安装在/bin)
  • 虽然您可能应该尽可能地将 ffmpeg 安装合并到 Dockerfile 中,但如果您确实需要访问容器,请使用 nsenter 包中的 docker-enter。使用docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter 安装。请参阅github.com/jpetazzo/nsenter 了解更多信息。

标签: go docker google-compute-engine


【解决方案1】:

更好的方法是通过在 Dockerfile 中添加 RUN 来将 ffmpeg 安装到您的 golang 容器中,例如

RUN apt-get update RUN apt-get install -y ffmpeg

modifyingDocker Containerrunning shell这几个字,与Docker的意思有点矛盾。

【讨论】:

    【解决方案2】:

    如果还需要安装额外的编解码器,安装 ffmepeg 并不那么简单,这就是我想在编写 docker 脚本之前使用 shell 的原因(从 cellofellow/ffmpeg 复制 Docker 脚本可以工作)。

    这里描述了问题的答案:https://github.com/docker-library/golang/issues/27

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-20
      • 2015-10-13
      • 1970-01-01
      • 2016-03-04
      • 1970-01-01
      • 1970-01-01
      • 2018-12-26
      相关资源
      最近更新 更多