Skip to content

Instantly share code, notes, and snippets.

@cweedall
Created August 21, 2020 00:10
Show Gist options
  • Save cweedall/e20f91729b3dccfbbaa7a0acc81cb233 to your computer and use it in GitHub Desktop.
Save cweedall/e20f91729b3dccfbbaa7a0acc81cb233 to your computer and use it in GitHub Desktop.
Method to use `migrate` and `makemigrations` commands in Django which is running in Docker container (via docker-compose)
# Assume django in container named web
# Use `python3` instead of `python` if necessary
docker-compose run web python manage.py migrate
docker-compose run web python manage.py makemigrations APP_NAME
#######################################################
### example docker-compose.yaml file
#######################################################
version: '3'
services:
db:
image: postgres
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
#######################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment