title: Running nginx and gunicorn in the same docker file
body: <p>I have a <code>Dockerfile</code> which at the end runs <code>run.sh</code>.</p>
  <p>I want to run gunicorn on port 8000 and proxy requests on 80 to 8000 with nginx.</p>
  <p>The problem is running server is a blocking command and it never executes <code>nginx -g 'daemon off;'</code>.</p>
  <p>What can I do to handle this situation?</p>
  <p>Here is the <code>run.sh</code> file:</p>
  <pre><code>python manage.py migrate --noinput
  gunicorn --bind=0.0.0.0:8000 bonit.wsgi:application &amp;
  nginx -g 'daemon off;'
  </code></pre>
  <p>And this the <code>Dockerfile</code>:</p>
  <pre><code>FROM python:3.8
  
  # set work directory
  WORKDIR /usr/src/app
  
  # set environment varibles
  ENV PYTHONDONTWRITEBYTECODE 1
  ENV PYTHONUNBUFFERED 1
  
  RUN apt-get update &amp;&amp;  apt-get install -y nginx supervisor build-essential gcc libc-dev libffi-dev default-libmysqlclient-dev libpq-dev
  RUN apt update &amp;&amp; apt install -y python3-pip python3-cffi python3-brotli libpango-1.0-0 libpangoft2-1.0-0
  
  RUN pip install --upgrade pip
  COPY requirements.txt .
  RUN pip install -r requirements.txt
  COPY . .
  
  RUN adduser --disabled-password --gecos '' nginx
  COPY nginx.conf /etc/nginx/nginx.conf
  
  RUN python manage.py collectstatic --noinput
  
  ENTRYPOINT [&quot;sh&quot;, &quot;/usr/src/app/run.sh&quot;]
  </code></pre>
  <p>And here is the <code>nginx.conf</code>:</p>
  <pre><code>user nginx;
  worker_processes auto;
  error_log /var/log/nginx/error.log;
  pid /var/run/nginx.pid;
  
  events {
      worker_connections 1024;
  }
  
  http {
      include /etc/nginx/mime.types;
      default_type application/octet-stream;
      access_log /var/log/nginx/access.log;
  
      upstream app {
          server app:8000;
      }
  
      server {
          listen 80;
          server_name 127.0.0.1;
          charset utf-8;
  
          location /static/ {
              alias /static/;
          }
  
          location / {
              proxy_pass http://app;
          }
      }
  }
  </code></pre>