Docker Compose与Dockerfile有什么区别 [英] What's the difference between Docker Compose vs. Dockerfile
问题描述
我一直在阅读和学习 Docker ,并且正在尝试正确选择要使用的Django设置.到目前为止,有两种情况:
I have been reading up and learning about Docker, and am trying to correctly choose the Django setup to use. So far there is either:
Docker Compose 或我了解到 Docker Compose
中使用了 Dockerfiles
,但是我不确定将所有内容放入一个具有多个 FROM的大型Dockerfile中是否是一种好习惯
命令用于不同的图像?
I understand that Dockerfiles
are used in Docker Compose
, but I am not sure if it is good practice to put everything in one large Dockerfile with multiple FROM
commands for the different images?
我想使用几张不同的图像,包括:
I want to use several different images that include:
uwsgi
nginx
postgres
redis
rabbitmq
celery with cron
请提供关于使用 Docker 设置此类环境的最佳实践的建议.
Please advise on what are best practices in setting up this type of environment using Docker.
如果有帮助,我在Mac上,因此使用 boot2docker .
If it helps, I am on a Mac, so using boot2docker.
我遇到的一些问题:
- Docker Compose与Python3不兼容
- 我想容器化我的项目,所以如果一个大的Dockerfile是不理想的,那么我觉得我需要使用Docker Compose对其进行分解
- 我可以将项目Py2&Py3兼容,因此倾向于django-compose
推荐答案
答案都不是.
Docker Compose(以下称为compose)将使用Dockerfile.
Docker Compose (herein referred to as compose) will use the Dockerfile if you add the build command to your project's docker-compose.yml
.
您的Docker工作流程应该是为要创建的每个映像构建一个合适的 Dockerfile
,然后使用compose通过 build
命令组装映像.
Your Docker workflow should be to build a suitable Dockerfile
for each image you wish to create, then use compose to assemble the images using the build
command.
您可以使用 build/path/to/dockerfiles/blah
指定单个Dockerfile的路径,其中/path/to/dockerfiles/blah
是blah的 Dockerfile
存在.
You can specify the path to your individual Dockerfiles using build /path/to/dockerfiles/blah
where /path/to/dockerfiles/blah
is where blah's Dockerfile
lives.
这篇关于Docker Compose与Dockerfile有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!