How do I serve static files from either gunicorn or nginx

I am playing with a docker project. Django+gunicorn in one container, nginx in another container.

When I switched over from the Django dev server to gunicorn, I noticed that all my static files weren’t being served. I’ve been trying to troubleshoot this for days thinking it was an nginx issue, but if I visit the container of Django/gunicorn (and not nginx), I also don’t see static files showing up here, so this makes me think it is not an nginx issue but just a simple error in my Django settings?

  • What should WSO2 APIM <localMemberHost> parameter contain in the config and what it is used by the APIM?
  • swift build faild due to “database is locked” in docker contianer?
  • How can I get a docker container to load text from /etc/motd
  • How to send node.js logs to Cloudwatch Logs from Elastic Beanstalk Docker application?
  • docker-machine, create and run a nginx container is not exposing port 80
  • Docker Keep Exiting (Deploying MS SQL on MAC osx)
  • Django settings.py

    DEBUG = False
    STATIC_ROOT = os.path.join(PACKAGE_ROOT, "static1")
    STATIC_URL = "/static/"
    STATICFILES_DIRS = [
        os.path.join(PACKAGE_ROOT, "static"),
    ]
    
    STATICFILES_FINDERS = [
        "django.contrib.staticfiles.finders.FileSystemFinder",
        "django.contrib.staticfiles.finders.AppDirectoriesFinder",
    ]
    

    nginx

    server {
        listen 80;
        server_name example.org;
        charset utf-8;
    
        location /static {
            alias /root/proj/proj/static;
        }
    }
    

    Note: I set this alias to /root/proj/proj/static, because this is the directory path to where static files are actually located inside the Django/gunicorn container… Am I correct in setting the alias to this path?

    docker-compose

    parentserver:
      build: ./parentserver
      expose:
        - "8000"
      links:
        - postgres:postgres
        - authserver:authserver
      volumes:
        - /usr/src/app
        - /usr/src/app/static
      env_file: .env
      environment:
        DEBUG: 'true'
      command: ./startup.sh
    
    nginx:
      build: ./nginx/
      ports:
        - "80:80"
      volumes:
        - /www/static
      volumes_from:    
        - parentserver
      links:
        - parentserver:parentserver
    

    Are my volumes set wrong?

    Would appreciate any feedback suggestions.

  • Docker: Change word in file at container startup
  • Container Based Application Clustering System
  • Dynamically start new Docker containers when needed?
  • Unable to connect the client to the server using Docker COntainers
  • Kubernetes pod running out of memory when writing to a volume mount
  • running docker from gradle: cannot pull image
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.