如何扩展现有的 docker 镜像? [英] How to extend an existing docker image?

查看:32
本文介绍了如何扩展现有的 docker 镜像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 官方的 elasticsearch Docker 镜像,而不是设置我自己的弹性搜索实例.这非常有效,直到我想扩展它为止.我想将 marvel 安装到该 ElasticSearch 实例中以获取更多信息.

I'm using the official elasticsearch Docker image instead of setting up my own elastic search instance. And that works great, up to the point when I wanted to extend it. I wanted to install marvel into that ElasticSearch instance to get more information.

现在 dockerfile/elasticsearch 自动运行 ElasticSearch 并将命令设置为 /bin/bash 不起作用,附加到容器或尝试通过 SSH 访问它,也不安装 ssh-daemon使用 apt-get install -y openssh-server.

Now dockerfile/elasticsearch automatically runs ElasticSearch and setting the command to /bin/bash doesn't work, neither does attaching to the container or trying to access it over SSH, nor installing ssh-daemon with apt-get install -y openssh-server.

在这种特殊情况下,我可以进入容器的文件系统并执行 opt/elasticsearch/bint/plugin -i elasticsearch/marvel/latest 并且一切正常.

In this particular case, I could just go into the container's file system and execute opt/elasticsearch/bint/plugin -i elasticsearch/marvel/latest and everything worked.

但是当我在运行的容器中没有终端时,如何安装需要使用 apt-get 安装的附加服务?

But how could I install an additional service which needs to be installed with apt-get when I can't have a terminal inside the running container?

推荐答案

只需使用以 Dockerfile 开头的 Dockerfile 进行扩展

Simply extend it using a Dockerfile that start with

FROM dockerfile/elasticsearch

并安装 marvel 或 ssh-server 或任何您需要的东西.然后,以正确的命令结束以启动您的服务.您可以使用 supervisor 来启动多个服务,参见 运行一个在 docker 容器中自动提供服务以获取更多信息.

and install marvel or ssh-server or whatever you need. Then, end with the correct command to start your services. You can use supervisor to start multple services, see Run a service automatically in a docker container for more info on that.

这篇关于如何扩展现有的 docker 镜像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆