Docker Community Forums

Share and learn in the Docker community.

Capture multi-stage exits that involve maven?

If service1 has a linked dependency linked to another that doesn’t exit - with a docker-compose.yml of

services:
  service1:
    build:
      context: .
      dockerfile: Dockerfile.service1
    depends_on:
      - service2
    links:
      - service2
  service2:
    container_name: service2
    depends_on:
      - service3
    build:
      context: .
      dockerfile: Dockerfile.service2
    service3:
      image: thisdoesntexit

When I have service1 building first as a multi-stage,

FROM <docker stage 1>
COPY . .
RUN echo "docker stage 1"

FROM <docker stage 2>
COPY . .
RUN echo "docker stage 2"
CMD mvn test

FROM <docker stage 3>
COPY . .
RUN echo "docker stage 3"
CMD mvn test

I never get to stage 2 or stage 3. I see an exit 0 from stage 1 only.