Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gunicorn running in Docker container with docker-compose #1533

Closed
andrewgy8 opened this issue Jun 21, 2017 · 0 comments
Closed

Gunicorn running in Docker container with docker-compose #1533

andrewgy8 opened this issue Jun 21, 2017 · 0 comments

Comments

@andrewgy8
Copy link

andrewgy8 commented Jun 21, 2017

The other day I created a standalone docker container with Gunicorn serving a Flask app. Everything worked fine.

Yesterday, I created a docker-compose file to run all the containers including Nginx and now the same command fails to start the Gunicorn process properly. I cant even serve the application directly when I expose the Gunicorn port 8000.

Here is the docker-compose.yml:

version: '2'
 
services:
  web:
    restart: always
    build: ./web_app
    expose:
      - "8000"
    ports:
      - "8000:8000"
    volumes:
      - ./web_app:/data/web
    command: /usr/local/bin/gunicorn web_interface:app -w 4 -t 90 --log-level=debug -b 0.0.0.0:8000 --reload
    depends_on:
      - postgres
 
  nginx:
    restart: always
    build: ./nginx
    ports:
     - "8080:80"
    volumes_from:
      - web
    depends_on:
      - web
 
  postgres:
    restart: always
    image: postgres:latest
    volumes_from:
      - data
    volumes:
      - ./postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
      - ./backups/postgresql:/backup
    expose:
      - "5432"

  data:
    restart: always
    image: alpine
    volumes:
      - /var/lib/postgresql
    tty: true

The errors I get in my terminal are
screen shot 2017-06-21 at 1 53 49 pm

Any idea why this might be happening?

When I navigate to localhost:8000 I get nothing rendered. And then when i navigate to localhost:8080 I get a 504 error.

Thanks for the help!

EDIT

Ok, so after three days of bashing my head, I re-started from the ground up. Rebuilt the app container and ran gunicorn.

From there I was able to determine that the gunicorn process was timing out because the database host name was incorrect. Instead of the an error being returned through my application, the failure went silent.

I fixed this by linking the postgres container and the web container. In my code I was able to use "postgres" (the name of the container) as the postgres host name.

Check the addresses to your external hosts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant