So I was working on a Macbook (with intel chip) and used the django-cookie-cutter template to start my project. Everything was working fine there.
I then switched to a new mac with apple chip. Now my changes on host machine are not replicated in the docker container i.e the container is not restarted automatically.
In my docker file, I have a 'docs' container which does restart on changes, but for the django container, I have to stop it manually with cmd+c and then restart it for my changes to take effect.
Here's my local.yml (docker compose) file:
version: '3'
volumes:
papersdb_local_postgres_data: {}
papersdb_local_postgres_data_backups: {}
services:
django:
build:
context: .
dockerfile: ./compose/local/django/Dockerfile
image: papersdb_local_django
container_name: papersdb_local_django
platform: linux/x86_64
depends_on:
- postgres
volumes:
- type: bind
source: .
target: /app
working_dir: /app
env_file:
- ./.envs/.local/.django
- ./.envs/.local/.postgres
ports:
- "8000:8000"
command: /start
postgres:
build:
context: .
dockerfile: ./compose/production/postgres/Dockerfile
image: papersdb_production_postgres
container_name: papersdb_local_postgres
volumes:
- papersdb_local_postgres_data:/var/lib/postgresql/data:Z
- papersdb_local_postgres_data_backups:/backups:z
env_file:
- ./.envs/.local/.postgres
ports:
- "5433:5432"
docs:
image: papersdb_local_docs
container_name: papersdb_local_docs
platform: linux/x86_64
build:
context: .
dockerfile: ./compose/local/docs/Dockerfile
env_file:
- ./.envs/.local/.django
volumes:
- ./docs:/docs:z
- ./config:/app/config:z
- ./papersdb:/app/papersdb:z
ports:
- "9000:9000"
command: /start-docs
Here's the bind mount in result of docker inspect my_container_name:
"Mounts": [
{
"Type": "bind",
"Source": "/Users/mazhar.ali/Projects/PapersDB/papersdb",
"Destination": "/app",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
I also have another project with celery and celerybeat, both of them restart on changes too. It's just the django container that's creating issues.
I had backed up my mac into another drive with 'Time Machine'. Then reinstalled docker desktop and reinstalled it (since the old one wasn't working on the new chip), which deleted all the containers and volumes. I am not sure if it has something to do with that.