Docker Community Forums

Share and learn in the Docker community.

Docker-compose file auto-reload doesnt work with second docker file

Two identical docker compose files .What I am having trouble understanding is , why is it that the normal docker-compose file ie running docker-compose up live reload works, with my Django project. Yet my test enviroment does not ie docker-compose -f test.yml up. The reason for 2 files is that I want to create a test environment that contains a pre populated db etc…, and the other environemt a "normal " dev environment.

docker-compose.yml

services:
    web:
        build: 
          dockerfile: ./compose/django/Dockerfile
          context: .
        container_name: main_app_django
        env_file: 
          - ./.local/.env
        command: compose/django/start.sh
        volumes:
          - .:/code
        ports:
          -  "8000:8000"
    
    redis:
      container_name: main_app_redis
      image: "redis:alpine"
      command: redis-server
      ports:
        - "6379:6379"
    

    celeryworker:
      build: 
        dockerfile: ./compose/celery/Dockerfile
        context: .
      container_name: main_app_celery
      command: celery -A app worker -l INFO
      env_file: 
        - ./.local/.env
      volumes:
        - .:/code 
      depends_on:
        - redis

test.yml

version: "3.9"

services:
    web:
      build: 
        dockerfile: ./compose/django/Dockerfile
        context: .
      container_name: test_main_app_django
      env_file: 
        - ./.local/.env
      command: > 
        sh -c "python manage.py makemigrations &&
          python manage.py migrate && python manage.py testserver cypress/fixtures/user.json cypress/fixtures/tracks.json --addrport 0.0.0.0:8000"
      volumes:
        - .:/code
      ports:
        -  "8000:8000"
    
    redis:
      container_name: test_main_app_redis
      image: "redis:alpine"
      command: redis-server
      ports:
        - "6379:6379"
    
    celeryworker:
      build:
        dockerfile: ./compose/celery/Dockerfile
        context: .
      container_name: test_main_app_celery
      command: celery -A appworker -l INFO
      env_file: 
        - ./.local/.env
      volumes:
        - .:/code
      depends_on:
        - redis

I don’t fully understand the question. What do you want to “reload”? What was the initial state, what did you expect to happen and what happened actually?

If you want to switch between the two environments or change something in one envrionment and deploy the new containers?

When I modify a file, the docker container reloads as expected , only with the normal compose file. When I run the test environment (test.yml), live reload doesnt work anymore. These environments are not running simlutaneously, I just want to be able to have a test environment, seperate from my dev environment