[Django]-Prevent skip in docker-compose

5👍

You can start your db container in Detached mode before building web:

$ docker-compose up -d db
$ docker-compose build web

Though, this seems like an anti-pattern. I would recommended that you keep the build process for web as generic as possible, and instead use environment variables or command arguments to accomplish this.

For instance, if you need to pass the same configuration values to both web and db, you could accomplish this using an env_file:

# db_credentials.env
USER="django"
PASSWORD="********"
DATABASE="django_db"

And in your docker-compose.yml file:

services:
  db:
    # ...
    env_file: db_credentials.env

  web:
    # ...
    env_file: db_credentials.env
👤damon

Leave a comment