Docker Compose 与 Dockerfile 有什么区别 [英] What's the difference between Docker Compose vs. Dockerfile

查看:50
本文介绍了Docker Compose 与 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 ComposeDockerfile

我知道在 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.

我遇到的一些问题:

  1. Docker Compose 与 Python3 不兼容
  2. 我想容器化我的项目,所以如果一个大的 Dockerfile不理想,那么我觉得我需要使用 Docker Compose 将其分解
  3. 我可以制作 Py2 & 项目Py3 兼容,所以我倾向于 django-compose

推荐答案

答案都不是.

Docker Compose(此处称为 compose)将使用 Dockerfile,如果您将构建命令添加到项目的 docker-compose.yml.

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,然后使用 build 命令使用 compose 来组装图像.

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屋!

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