Docker 端口在 localhost 中工作,但在 public ip 中不工作

Docker ports work in localhost but not with public ip

我从 docker 开始 我有下一个 docker-compose 当我 运行 docker-compose 成功时,当我 curl localhost工作正常但是当我尝试从 public ip 访问时连接超时。

version: '3'
services:
  db:
   environment:
     - POSTGRES_PASSWORD=mipass
     - POSTGRES_USER=miuser
     - POSTGRES_DB=pdfdd
   image: postgres:9.6
  web:
   restart: always
   tty: true
   stdin_open: true
   build: .
   command: python ./code/manage.py runserver 0.0.0.0:8000
   volumes:
     - .:/code
   ports:
     - "8000:8000"
   depends_on:
     - db
  nginx:
    restart: always
    build: ./nginx/
    ports:
      - "80:80"
    volumes:
      - /www/static
      - .:/code
    links:
      - web:web

感谢@BMitch,我忘记在安全组中打开 80 端口,如果有人遇到相同的错误,请参阅 Opening port 80 EC2 Amazon web services 以获取说明。