title: How to combine nginx socket with gunicorn app using that socket inside docker?
body: <p>I have developed a small project using flask/tensorflow. It runs under app server - gunicorn.
  I have to also include nginx into the project for serving static files. Without docker app is running fine. All parts(gunicorn, nginx, flask) cooperate as intended. It's now time to move this project to an online server, and i need to do it via docker.</p>
  <p><strong>Nginx</strong> and <strong>gunicorn-&gt;flask</strong> app communicate via <strong>unix socket</strong>. In my localhost environment i used socket inside app root folder - myapp/app.sock, it all worked great.</p>
  <p>Problem now is that i can't quite understand how do i tell nginx inside docker to use same socket file and tell gunicorn to listen to it. I get the following error:</p>
  <p><strong>upstream: http:// unix:/var/run/app.sock failed (No such file or directory) while connecting to upstream</strong></p>
  <p>Tried using different paths to socket file, but no luck - same error.</p>
  <p><strong>docker-compose file:</strong></p>
  <pre><code>version: '3'
  services:
    nginx:
      image: nginx:latest
      volumes:
        - ./nginx/nginx.conf:/etc/nginx/nginx.conf
        - ./nginx/remote-app:/etc/nginx/sites-enabled/remote-app
        - /etc/nginx/proxy_params:/etc/nginx/proxy_params
      ports:
        - 8000:8000
      
      build: .
      command: gunicorn --bind unix:/var/run/app.sock wsgi:app --reload --workers 1 --timeout 60
      
      environment:
        - FLASK_APP=prediction_service.py
        - FLASK_DEBUG=1
        - PYTHONUNBUFFERED=True
      restart: on-failure
  </code></pre>
  <p><strong>main Dockerfile</strong> (for main app, it builds app fine, all is working):</p>
  <pre><code>FROM python:3.8-slim
  
  RUN pip install flask gunicorn flask_wtf boto3 tqdm
  RUN pip install numpy==1.18.5
  RUN pip install tensorflow==2.2.0 onnxruntime==1.4.0
  
  COPY *.ipynb /temp/
  COPY *.hdf5 /temp/
  COPY *.onnx /temp/
  COPY *.json /temp/
  COPY *.py /temp/
  
  WORKDIR /temp
  </code></pre>
  <p><strong>nginx.conf</strong> is 99% same as default with only increased file size for uploading to 8M
  proxy-params is just a preset of configurtion params for making nginx proxy requests
  and remote-app is a config for my app(simple one):</p>
  <pre><code>server {
      listen 8000;
      server_name localhost;
  
     location / {
        include proxy_params;
        proxy_pass htpp://unix:/var/run/app.sock; //**tried /temp/app.sock here same issue**
  }
  }
  </code></pre>
  <p>So if i open localhost(even without port 8000) i can get nginx answer. If i try to open localhost:8000 i get that socket error( that is pasted above with strong text ).</p>