I found this answer from Michael Hampton : βThis only works if the processes are on the same host, virtual machine or container, because it is trying to connect to the same machine. When they are in different containers, this does not work.
You need to change the nginx configuration so that it uses the internal IP address of the uwsgi container. Link from message
And definitely you need to keep in mind if you have Nginx in another container, you should also install nginx.conf, specifying your statics directory file as an alias to prevent a security problem.
Hope this code works for everyone, it took me a few people to figure out how to compose Gunicorn, docker and Nginx:
# nginx.conf upstream djangoA { server $DOCKER_CONTAINER_SERVICE:9000 max_fails=3 fail_timeout=0;
And for docker-compose:
#production.yml version: '2' services: db: extends: file: base.yml service: db nginx: image: nginx:latest volumes: - ./nginx:/etc/nginx/conf.d/ - ./$STATIC_FILE_ROOT/site_media:/$STATIC_FILE_ROOT/site_media ports: - "80:80" depends_on: - web web: extends: file: base.yml service: web build: args: - DJANGO_ENV=production command: bash -c "python manage.py collectstatic --noinput && chmod 775 -R project/site_media/static && gunicorn project.wsgi:application" volumes: - ./$DIRECTORY_APP:/$DIRECTORY_APP ports: - "9000:9000" depends_on: - db volumes: db_data: external: true
Cam t
source share