Docker - 无法向外部站点发出 URL 请求

问题描述 投票:0回答:1

这是第一个 Docker 项目,我不是 IT 人员。

我使用 Django Cookiecutter 安装了 Docker。

https://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html

在我尝试执行 URL 请求之前,一切似乎都很好。我认为这是某种港口之类的东西?

只是一个简单的请求是行不通的。

response = requests.get(url)

我似乎也无法使用我的外部 Pdf 源。 (DocRaptor)

谢谢。

这里是local.yml:

  version: '3'

  volumes:
    prelim_local_postgres_data: {}
    prelim_local_postgres_data_backups: {}

  services:
    django: &django
      build:
        context: .
        dockerfile: ./compose/local/django/Dockerfile
      image: prelim_local_django
      container_name: prelim_local_django
      depends_on:
        - postgres
        - redis
        - mailhog
      volumes:
        - .:/app:z
      env_file:
        - ./.envs/.local/.django
        - ./.envs/.local/.postgres
      ports:
        - "8000:8000"
      command: /start

    postgres:
      build:
        context: .
        dockerfile: ./compose/production/postgres/Dockerfile
      image: prelim_production_postgres
      container_name: prelim_local_postgres
      volumes:
        - prelim_local_postgres_data:/var/lib/postgresql/data
        - prelim_local_postgres_data_backups:/backups
      env_file:
        - ./.envs/.local/.postgres
      ports:
        - "5432:5432"

    nginx-proxy:
      image: jwilder/nginx-proxy:alpine
      container_name: nginx-proxy
      ports:
        - "80:80"
        - "443:443"
      volumes:
        - /var/run/docker.sock:/tmp/docker.sock:ro
  #      - ./certs:/etc/nginx/certs
      restart: always
      depends_on:
        - django

    whoami:
      image: jwilder/whoami
      environment:
        - VIRTUAL_HOST=whoami.local

    mailhog:
      image: mailhog/mailhog:v1.0.0
      container_name: prelim_local_mailhog
      ports:
        - "8025:8025"

    redis:
      image: redis:6
      container_name: prelim_local_redis

    celeryworker:
      <<: *django
      image: prelim_local_celeryworker
      container_name: prelim_local_celeryworker
      depends_on:
        - redis
        - postgres
        - mailhog
      ports: []
      command: /start-celeryworker

    celerybeat:
      <<: *django
      image: prelim_local_celerybeat
      container_name: prelim_local_celerybeat
      depends_on:
        - redis
        - postgres
        - mailhog
      ports: []
      command: /start-celerybeat

    flower:
      <<: *django
      image: prelim_local_flower
      container_name: prelim_local_flower
      ports:
        - "5555:5555"
      command: /start-flower

    node:
      build:
        context: .
        dockerfile: ./compose/local/node/Dockerfile
      image: prelim_local_node
      container_name: prelim_local_node
      depends_on:
        - django
      volumes:
        - .:/app:z
        - /app/node_modules
      command: npm run dev
      ports:
        - "3000:3000"
        - "3001:3001"
django docker url
1个回答
0
投票

上面的设置很好。这不是任何类型的端口或 URL 问题。

Django Cookiecutter 安装:

Werkzeug[watchdog]==2.2.3    # https://github.com/pallets/werkzeug

“看门狗”不断中断 URL 调用。

仅更改为 Werkzeug==2.2.3 解决了我的代码被中断和崩溃的问题。

© www.soinside.com 2019 - 2024. All rights reserved.