Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ordered build of nested docker images with compose

I am building a lamp with docker-compose.

In my docker-compose.yml i have the following:

ubuntu-base:
    build: ./ubuntu-base

webserver-base:
    build: ./webserver-base

webserver-base is derived from the ubuntu-base image. In webserver-base Dockerfile:

FROM docker_ubuntu-base

ubuntu-base is built

FROM ubuntu:14.04

Now, if i execute the docker-compose.yml, it does not build the ubuntu-base image, but its trying to build the webserver-base image and fails, because it does not find the ubuntu-base image.

Output:

$ docker-compose up -d
Building webserver-base
Step 1 : FROM docker_ubuntu-base
Pulling repository docker.io/library/docker_ubuntu-base
ERROR: Service 'webserver-base' failed to build: Error: image library/docker_ubuntu-base:latest not found

It all works if i build the ubuntu-base image manually first.

why does it not build the ubuntu-base image?

like image 726
cari Avatar asked Jan 06 '23 23:01

cari


1 Answers

Sadly, build ordering is a missing feature in docker-compose, that is requested for many month now.

As workaround you can link the containers like this:

ubuntu-base:
    build: ./ubuntu-base

webserver-base:
    build: ./webserver-base
    links:
      - ubuntu-base

this way ubuntu-base gets built before webserver-base.

like image 171
cari Avatar answered Jan 15 '23 01:01

cari