I am attempting to take a working django production web app and containerize it. Every time it fails binding a port. When I check the port docker already owns it. When I do a sudo docker-compose down, the port is release. I am suspicious it is in my compose file as I use nginx and uwsgi. Here is my yml file:
version: '3.8'
services:
web:
build:
context: /opt/dlnWebApplication
volumes:
- /opt/dlnWebApplication:/app
- sqlite_data:/app/db # Ensure volume for SQLite database
ports:
- "8081:80" # Map the container's port 80 to the host's port 8080 (testing purpose)
environment:
- DJANGO_SETTINGS_MODULE=dlnWebApplication.settings
cron:
build:
context: /opt/dlnEquipmentSnooper
volumes:
- /opt/dlnEquipmentSnooper:/app
- sqlite_data:/app/db # Ensure cron uses the same SQLite file
depends_on:
- web
environment:
- DJANGO_SETTINGS_MODULE=dlnWebApplication.settings
nginx:
image: nginx:latest
volumes:
- ./docker.dlnWebApplication.conf:/etc/nginx/conf.d/default.conf
- /opt/dlnWebApplication/static:/app/static # Match Docker paths
- /opt/dlnWebApplication/media:/app/media # Match Docker paths
- ./logs:/var/log/nginx # Optionally map logs for debugging
ports:
- "8081:80" # Map container's port 80 to host's port 8080 for testing
depends_on:
- web
volumes:
sqlite_data:
I believe nginx have to run on the same port as the web app.
Any help truly appreciated,
Doug
1