Docker Community Forums

Share and learn in the Docker community.

Docker Compose Build Dependent Layers?


(Dgarstang) #1

I would like docker-compose to build all the dependent images for a container. If my docker-compose file contains:

version: '2’
services:
foo-ubuntu:
build: foo-ubuntu
image: foo-ubuntu
container_name: foo-ubuntu
ports:
- "5000:5000"
volumes:
- .:/code

foo-oracle-java8:
build: foo-oracle-java8
image: foo-oracle-java8
container_name: foo-oracle-java8
ports:
- "5000:5000"
volumes:
- .:/code

foo-tomcat:
build: foo-tomcat
image: foo-tomcat
container_name: foo-tomcat
ports:
- "5000:5000"
volumes:
- .:/code

foo-webapp-dt-dev:
build:
context: foo-webapp-dt
args:
ENV: dev
BRANCH: stable
VERSION: 6.7.683
container_name: foo-webapp-dt-dev

and I run ‘docker-compose build foo-webapp-dt-dev’, then I would hope it would build all the defendant images. There is no ‘link’ between the images in the docker-compose.yml file, so I would assume docker-compose could inspect each images Dockerfile, look at the FROM: line, look for that in docker-compose and then build that dependency first.

The up command to docker-compose isn’t what I need as I don’t want to run these images, just use them as layers.

Thanks,
Doug