简体   繁体   中英

docker-compose: django, development server not listening?

I have been following along this simple tutorial about setting up a simple django/postgres project with docker compose. I have made some minor modifications to the docker-compose.yml file which now looks like this:

version: '2'
services:
  db:
    image: postgres
  web:
    build: .
    command: bash -c "python manage.py migrate && python manage.py makemigrations && python manage.py runserver 9000"
    volumes:
      - .:/code
    ports:
      - "9000:9000"
    depends_on:
      - db

However when hitting 127.0.0.1:9000 on my browser I get

This site can't be reached

Here is the terminal output:

Starting wdocker_db_1
Starting wdocker_web_1
Attaching to wdocker_db_1, wdocker_web_1
db_1   | LOG:  database system was shut down at 2016-04-27 13:09:55 UTC
db_1   | LOG:  MultiXact member wraparound protections are now enabled
db_1   | LOG:  database system is ready to accept connections
db_1   | LOG:  autovacuum launcher started
web_1  | Operations to perform:
web_1  |   Apply all migrations: sessions, contenttypes, admin, auth
web_1  | Running migrations:
web_1  |   No migrations to apply.
web_1  | No changes detected

and here is the sudo netstat -tulpn | grep 9000 sudo netstat -tulpn | grep 9000 output

tcp6 0 0 :::9000 :::* LISTEN 15022/docker-proxy

您需要像这样在0.0.0.0:9000上收听django:

command: bash -c "python manage.py migrate && python manage.py makemigrations && python manage.py runserver 0.0.0.0:9000"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM