Docker启动我的django服务器并说它的速度为0.0.0.0:8000,但是我无法在浏览器中访问它,0.0.0.0:8000或127.0.0.1:8000都无法正常工作

web_1  | You have unapplied migrations; your app may not work properly until
they are applied.
web_1  | Run 'python manage.py migrate' to apply them.
web_1  | April 30, 2017 - 03:36:35
web_1  | Django version 1.8.5, using settings 'my_project.settings'
web_1  | Starting development server at http://0.0.0.0:8000/
web_1  | Quit the server with CONTROL-C.

Docker文件
version: '2'
services:
  db:
    image: postgres
  web:
    build: .
    command: python3 manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

最佳答案

您是否将主机上的端口映射到容器上的端口8000?例如,您可以在--publish 1234:8000命令中指定docker run将主机端口1234映射到容器端口8000,然后通过http://localhost:1234/到达它。

关于django - Django不会从Docker开始,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43702834/

10-16 02:10