Reputation: 1222
How can i run two different django-cookie-cutter generated projects on the same server. The projects are generated using Docker. I guess we should change the ports to avoid collisons. But as there are so many configuration files any help is appreciated.
Upvotes: 0
Views: 52
Reputation: 366
You should have a 'production.yml' file. You should keep the rest of the files and services same. And just change the nginx configuration to accept traffic at different port. Your 'postgres' and 'django' services are accessed by other containers through names, and not the port that they expose. This should be your nginx configuration.
nginx:
build:
context: .
dockerfile: ./compose/production/nginx/Dockerfile
image: calcscore_python_local_nginx
depends_on:
- django
volumes:
- production_django_media:/usr/share/nginx/media:ro
ports:
- 8001:80
restart: unless-stopped
Now when you hit port 8001, it will go to the correct nginx container. And due to networking in docker compose, nginx container will know which postgres or django service it should access.
Upvotes: 0
Reputation: 1222
I included a port section for the services defined docker-compose.local.yml, including postgres, django, etc :
docker-compose.local.yml
services:
django: &django
ports:
- '8001:8000' #map host 8001 to container 8000
postgres:
ports:
- '5433:5432' #map Host port 5433 to container 5432
Upvotes: 0