Docker compose up before build

Viewed 13

Here is a simpler version of the docker compose file that I am using:

version:"3.9"

services:
  db:
    ...

  webapp:
    build:
      context: ./config
    depends on:
      - "db"
    ...

Whenever I run the command docker-compose up -d, here is the order of what Docker executes:

  1. Build the container for the web app
  2. If successful, it boots all containers based on the order of what the depends on requirement

I was wondering if that was possible to boot first the db service on its own, then build the web app, and finally boot everything? I need it since the build of the web app requires the database to be up and running for some build steps. I would like to keep everything in one docker-compose.yml file and with as few commands if possible.

Thanks for your help!

0 Answers
Related