Andrej Shulaev
Andrej Shulaev

Reputation: 58

Run two docker-compose files one after another, tiangolo image

I'm quite newbie with docker, so i found this image, which has pre-installed flask-uwsgi-nginx and I run it with following command:

docker-compose -f docker-compose.yml -f docker-compose.override.yml up

docker-compose.yml

version: '3'
  services:
    web:
      build: ./

docker-compose.override.yml

version: '3'
 services:
  web:
   volumes:
    - ./app:/app
    - /var/run/docker.sock:/var/run/docker.sock
   ports:
    - "80:80"
   environment:
    - FLASK_APP=app/main.py
    - FLASK_DEBUG=1
    - 'RUN=flask run --host=0.0.0.0 --port=80'

My question is, do i really need to run it with two compose files ? if so, why ?

Upvotes: 0

Views: 247

Answers (1)

mbuechmann
mbuechmann

Reputation: 5760

You do not have to use two files. You could merge these two files into one and just use it.

The second file overwrites already present settings from the first one. This can be useful in some situations. You could use different "overwrite" files to test different settings.

For example you are developing a web app. This web app has a regular configuration that is valid in any case. Those configs will be in docker-compose.yml. Now you start it during development in "dev mode". This mode has some configurations that you pass via docker-compose.dev.yml. You start your app with those two files and can work locally. After finishing your work, you want to test your app in "production mode". All configs for this mode reside in another file, namely docker-compose.prod.yml. You can now start the app in this mode, just by exchanging the second -f argument in docker-compose up.

The filenames docker-compose.yml and docker-compose.override.yml are not mandatory. If these files are present they are used per default.

Upvotes: 1

Related Questions