我正在设置一个简单的图像:一个保存Riak(一个NoSQL数据库).该图像riak start作为CMD 启动Riak服务.现在,如果我将它作为守护进程运行docker run -d quintenk/riak-dev,它确实启动了Riak进程(我可以在日志中看到它).但是,它会在几秒钟后自动关闭.如果我使用docker run -i -t quintenk/riak-dev /bin/bashriak进程运行它没有启动(更新:请参阅答案以获得解释).事实上,根本没有服务运行.我可以使用终端手动启动它,但我希望Riak自动启动.我认为其他服务也会出现这种情况,Riak只是一个例子.
因此,运行/重新启动容器应该会自动启动Riak.设置它的正确方法是什么?
作为参考,这里是用于创建图像的Dockerfile(更新:使用所选答案进行更改):
FROM ubuntu:12.04
RUN apt-get update
RUN apt-get install -y openssh-server curl
RUN curl http://apt.basho.com/gpg/basho.apt.key | apt-key add -
RUN bash -c "echo deb http://apt.basho.com precise main > /etc/apt/sources.list.d/basho.list"
RUN apt-get update
RUN apt-get -y install riak
RUN perl -p -i -e 's/(?<=\{http,\s\[\s\{")127\.0\.0\.1/0.0.0.0/g' /etc/riak/app.config
EXPOSE 8098
CMD /bin/riak start && tail -F /var/log/riak/erlang.log.1
Run Code Online (Sandbox Code Playgroud)
编辑:-f根据他的评论,在CMD中改为-F
在与Docker合作一段时间之后,我养成了使用supervisord来调整我的进程的习惯.如果您想要示例代码,请查看https://github.com/Krijger/docker-cookbooks.我使用我的主管图像作为我所有其他图像的基础.我在这里写了一篇关于使用主管的博客.
我已经下载了版本1.1.0的elasticsearch,它运行良好.我想安装marvel插件,所以我从elasticsearch主目录运行以下命令(完全像官方教程http://www.elasticsearch.org/guide/en/marvel/current/#_simple_install中所述) :
bin\plugin -i elasticsearch/marvel/latest
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
-> Installing elasticsearch/marvel/latest...
Trying http://download.elasticsearch.org/elasticsearch/marvel/marvel-latest.zip.
..
Trying http://search.maven.org/remotecontent?filepath=elasticsearch/marvel/lates
t/marvel-latest.zip...
Trying https://oss.sonatype.org/service/local/repositories/releases/content/elas
ticsearch/marvel/latest/marvel-latest.zip...
Trying https://github.com/elasticsearch/marvel/archive/vlatest.zip...
Trying https://github.com/elasticsearch/marvel/archive/master.zip...
Failed to install elasticsearch/marvel/latest, reason: failed to download out of
all possible locations..., use -verbose to get detailed information
Run Code Online (Sandbox Code Playgroud)
这就是我使用-verbose时得到的结果:
-> Installing elasticsearch/marvel/latest...
Trying http://download.elasticsearch.org/elasticsearch/marvel/marvel-latest.zip.
..
Failed: UnknownHostException[download.elasticsearch.org]
Trying http://search.maven.org/remotecontent?filepath=elasticsearch/marvel/lates
t/marvel-latest.zip...
Failed: UnknownHostException[search.maven.org]
Trying https://oss.sonatype.org/service/local/repositories/releases/content/elas
ticsearch/marvel/latest/marvel-latest.zip...
Failed: UnknownHostException[oss.sonatype.org]
Trying https://github.com/elasticsearch/marvel/archive/vlatest.zip...
Failed: UnknownHostException[github.com]
Trying https://github.com/elasticsearch/marvel/archive/master.zip...
Failed: UnknownHostException[github.com]
Failed to install elasticsearch/marvel/latest, reason: failed to download out of …Run Code Online (Sandbox Code Playgroud) tensorflow docker容器可以在https://hub.docker.com/r/tensorflow/tensorflow/上找到,以扩展这个容器和其他库,例如requests我知道有两个选项.
pip install requestspip install requests到dockerFile构建此容器的那个还有其他选择吗?类似于tensorflow/tensorflow从dockerFile 创建容器然后requests在此容器上安装的东西.
阅读如何扩展现有的泊坞窗图像?要完成这个创建一个包含这些内容的dockerFile?:
FROM tensorflow/tensorflow
RUN pip install requests
Run Code Online (Sandbox Code Playgroud)