Docker - 具有多个图像的容器 [英] Docker - container with multiple images
问题描述
我想制作一个包含多个镜像的 Dockerfile,以便在一个容器中运行.
I wanted to make a Dockerfile with multiple images to run in one container.
解决此问题的最佳方法是什么?下面是我想在单个容器中运行的列表.我在制作包含所有这些内容的 Dockerfile 时运气不佳.
What is the best method to go about this? Below is a list of what I wanted to run in a single container. I have not have any luck with making a Dockerfile with all of these included.
- MySQL 服务器
- RabbitMQ
- Java8
- Node.js
- Xvfb
- 火狐
- 铬
这就是我目前所拥有的,我可以得到一些提示
This is what I have so far, can I get a few tips
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"]
推荐答案
你不能在一个容器中运行多个图像",这没有意义.
You cannot have "multiple images to run in one container", that wouldn't make sense.
但是您可以编写一个 Dockerfile 来创建一个镜像,该镜像将安装您提到的所有服务.示例(Ubuntu/Debian 发行版):
But you can write a Dockerfile to create an image that will install all the services you mentionned. Example (Ubuntu/Debian distribution) :
[...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"]
然后您必须在容器启动时自动启动所有这些.
Then you would have to get all of them started automatically when the container starts.
您可以使用流程管理器,例如 supervisord(Docker 文档 这里).
You can use a process manager such as supervisord (Docker documentation here).
或者,您可以使用常规的初始化系统,检查这个基础镜像:ubuntu-upstart.这将允许您只需要在 Dockerfile 中安装软件包并通过将 /sbin/init 指定为 EntryPoint
或 来自动启动它们.CMD
在你的 Dockerfile 中.
Alternatively, you could use a regular init system, check this base image : ubuntu-upstart. This one would allow you to only have to install the packages in your Dockerfile and get them started automatically without any effort, by specifying /sbin/init as EntryPoint
or CMD
in your Dockerfile.
这篇关于Docker - 具有多个图像的容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!