我想要创建一个包含多个映像的Dockerfile,以便在一个容器中运行。
做这件事最好的方法是什么?下面是我想在单个容器中运行的内容列表。我没有任何运气做一个Dockerfile与所有这些都包括在内。
到目前为止,这就是我所拥有的,我能得到一些提示吗?
FROM stackbrew/ubuntu:12.04
MAINTAINER
# Update the repository sources list #RUN apt-get update
# My SQL Server ###############
RUN apt-get
update -qq && apt-get
install -y mysql-server-5.5
ADD my.cnf /etc/mysql/conf.d/my.cnf
RUN chmod 664 /etc/mysql/conf.d/my.cnf
ADD run /usr/local/bin/run
RUN chmod +x /usr/local/bin/run V
OLUME ["/var/lib/mysql"]
EXPOSE 3306
CMD ["/usr/local/bin/run"] 发布于 2014-05-13 17:11:57
您不能“在一个容器中运行多个映像”,这是没有意义的。
但是您可以编写一个Dockerfile来创建一个映像,该映像将安装您提到的所有服务。示例(Ubuntu/Debian发行版):
[...header...]
FROM stackbrew/ubuntu:12.04 #or use ubuntu-upstart:12.04
MAINTAINER BPetkov
# Update the repository sources list
RUN apt-get update -qq
# Mysql
RUN apt-get install -y mysql-server-5.5
ADD my.cnf /etc/mysql/conf.d/my.cnf
RUN chmod 664 /etc/mysql/conf.d/my.cnf
ADD run /usr/local/bin/run
RUN chmod +x /usr/local/bin/run
# Other stuff
RUN apt-get -y install rabbitmq
RUN apt-get -y install nodejs
[...]
VOLUME ["/var/lib/mysql"]
EXPOSE 3306
EXPOSE .......
CMD ["/sbin/init"]然后,当容器启动时,您必须让它们全部自动启动。
您可以使用流程管理器(如监督d (DockerDocuments这里))。
或者,您可以使用一个常规的init系统,检查这个基本映像:ubuntu-新贵。通过在Dockerfile中将/sbin/init指定为EntryPoint或CMD,您只需在Dockerfile中安装包并自动启动它们,而无需任何努力。
发布于 2016-05-07 21:25:01
您要寻找的功能是码头组成。
https://stackoverflow.com/questions/23636243
复制相似问题