我当前的项目包括mongo服务器,rabbitmq服务器和dotnet核心服务。它的结构如下:
.
??? project1.docker-compose.yml #multiple docker-compose files for all projects
??? .dockerignore
??? Util/
| ??? some common code across all projects
??? Project1/ #there are multiple projects at the same level with the same structure
??? .docker/
| ??? mongodb
| | ???Dockerfile
| ??? rabbitmq
| ???Dockerfile
??? BusinessLogicClasses/
| ??? some classes that contain my business logic
??? DotNetCoreService/
??? my service code
??? .docker
???Dockerfile
Run Code Online (Sandbox Code Playgroud)
现在,我能够使用docker-compose命令成功为mongodb,rabbitmq和dot net core构建映像。docker-compose.yml位于主目录级别,因为我的不同项目(在本例中为Project1)引用了在Util目录下找到的代码。因此,我需要能够提供两个目录上方的上下文,以便可以在Dockerfile上使用COPY操作。
我的基本project1.docker-compose.yml如下(我排除了不重要的部分)
version: '3'
services:
rabbitmq:
build:
context: Project1/.docker/rabbitmq/ …Run Code Online (Sandbox Code Playgroud)