Docker:项目中有多个Dockerfile [英] Docker: Multiple Dockerfiles in project

查看:704
本文介绍了Docker:项目中有多个Dockerfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您有一个用于数据库的Dockerfile,一个用于应用程序服务器的Dockerfile等时,如何组织属于项目的Dockerfile?您是否在源代码中创建了某种层次结构?
一个大型企业项目不能仅包含一个Dockerfile?

How do you organize the Dockerfiles belonging to a project when you have one Dockerfile for the database, one for the application server, and so on? Do you create some sort of hierachy in the source? A big enterprise project can't consist of only one Dockerfile?

推荐答案

作者注意



此答案已过期。无花果不再存在,并已由 Docker compose 取代。
不能删除接受的答案...。

Author Note

This answer is out of date. Fig not longer exists and has been replaced by Docker compose. Accepted answers cannot be deleted ....

Docker Compose支持构建项目层次结构。因此,现在很容易在每个子目录中支持Dockerfile。

Docker Compose supports the building of project hierachy. So it's now easy to support a Dockerfile in each sub directory.

├── docker-compose.yml
├── project1
│   └── Dockerfile
└── project2
    └── Dockerfile






原始答案



我只是为每个组件创建一个包含Dockerfile的目录。示例:


Original answer

I just create a directory containing a Dockerfile for each component. Example:

  • Setting up a docker / fig Mesos environment

仅在构建容器时输入目录名称,然后Docker将选择正确的Dockerfile。

When building the containers just give the directory name and Docker will select the correct Dockerfile.

这篇关于Docker:项目中有多个Dockerfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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