docker-compose remote interpreter with nginx

I followed these steps, and my Python/Django app is starting up according to the console (no errors):

https://www.jetbrains.com/help/pycharm/using-docker-compose-as-a-remote-interpreter.html

app_1 | September 10, 2020 - 15:14:49
app_1 | Django version 2.2.15, using settings 'project.settings'
app_1 | Starting development server at http://0.0.0.0:9000/
app_1 | Quit the server with CONTROL-C.

 

However, nothing seems to be listening on the port.

Unable to connect

Firefox can't establish a connection to the server at 0.0.0.0:9000.

Note that the difference between mine and the tutorial is that mine uses nginx, and the tutorial doesn't. In the run configuration I specify the port normally used to go via nginx.

 

version: '3'
services:

# Main application
app:
restart: always
build:
context: ./containers/app/
args:
- SSH_PRIVATE_KEY
env_file:
- ./config/env/files/app.env
volumes:
- ./containers/app/bin/:/app/bin/
- ./containers/app/src/:/app/code/src/
- ./containers/app/config/:/app/config/
- ./containers/app/config/postfix/main.cf:/etc/postfix/main.cf
- ./.git/:/app/.git/
- ./logs/app/:/app/logs/
# the line below mounts the XXXX repository at /lib for development.
# this should be commented out on any environment except dev
- ./containers/app/lib/:/app/code/lib/
- app_data:/app/data/
depends_on:
- postgres

# Main database server
postgres:
build: ./containers/postgres/
restart: unless-stopped
env_file:
- ./config/env/files/postgres.env
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- 5432:5432

# Nginx -> app uwsgi
nginx:
build:
context: ./containers/nginx/
args:
- SSH_PRIVATE_KEY
restart: unless-stopped
env_file:
- ./config/env/files/nginx.env
ports:
- ${PORT}:80
volumes:
- ./containers/nginx/bin/:/app/bin/
- ./containers/nginx/config/:/app/config/
- ./logs/nginx/nginx/:/var/log/nginx/
- app_data:/srv/data
depends_on:
- app

volumes:
postgres_data:
app_data:

 

 

Does anyone know if this setup is supported? Or what can I do to make it work?

Note, I can add this to my `app` definition in compose:

ports:
- "8000:8000"

...and also change the run configuration to use 8000 instead, but I'm just really curious if I can go via nginx.

0
2 comments

How do you expect nginx to do the port binding in this case?

Right now it looks like 9000 port you are using is not binded by docker so the request you make in a browser is not passed to the container.

0

I've put PORT=9000 in an `.env` file.

0

Please sign in to leave a comment.