0

我将 Directus 与 Docker 一起使用,一切正常。

现在我正在尝试使用 Webhook,但出现以下错误:当我尝试在集合中添加数据时,出现以下错误: “cURL 错误 7:无法连接到 localhost 端口 3001:连接被拒绝” 。

当我运行 docker ps 时:

CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                               NAMES
5e9c2b6c86e8        directus/directus:v8-apache   "directus-entrypoint…"   7 minutes ago       Up 7 minutes        0.0.0.0:8080->80/tcp                fire_directus_1
a3685d0a5f35        mysql:5.7                     "docker-entrypoint.s…"   7 minutes ago       Up 7 minutes        0.0.0.0:3306->3306/tcp, 33060/tcp   fire_mysql_1

我的码头工人撰写:

version: "3"
services:
  mysql:
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: "directus"
      MYSQL_USER: "directus"
      MYSQL_PASSWORD: "directus"
      MYSQL_ROOT_PASSWORD: "directus"
    ports:
      - "3306:3306"

  directus:
    image: directus/directus:v8-apache
    ports:
      - "8080:80"
    environment:
      DIRECTUS_APP_ENV: "production"
      DIRECTUS_AUTH_PUBLICKEY: "some random secret"
      DIRECTUS_AUTH_SECRETKEY: "another random secret"
      DIRECTUS_DATABASE_HOST: "mysql"
      DIRECTUS_DATABASE_PORT: "3306"
      DIRECTUS_DATABASE_NAME: "directus"
      DIRECTUS_DATABASE_USERNAME: "directus"
      DIRECTUS_DATABASE_PASSWORD: "directus"
    volumes:
      - ./data/config:/var/directus/config
      - ./data/uploads:/var/directus/public/uploads
    links:
      - mysql:mysql

我的网络钩子:

在此处输入图像描述

4

1 回答 1

2

看来您在 docker compose 中缺少网络配置。您必须将所有容器放在同一个网络中。我修改成这样的:

version: "3"
services:
  mysql:
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: "directus"
      MYSQL_USER: "directus"
      MYSQL_PASSWORD: "directus"
      MYSQL_ROOT_PASSWORD: "directus"
    ports:
      - "3306:3306"
    networks:
      - netnet

  directus:
    image: directus/directus:v8-apache
    ports:
      - "8080:80"
    environment:
      DIRECTUS_APP_ENV: "production"
      DIRECTUS_AUTH_PUBLICKEY: "some random secret"
      DIRECTUS_AUTH_SECRETKEY: "another random secret"
      DIRECTUS_DATABASE_HOST: "mysql"
      DIRECTUS_DATABASE_PORT: "3306"
      DIRECTUS_DATABASE_NAME: "directus"
      DIRECTUS_DATABASE_USERNAME: "directus"
      DIRECTUS_DATABASE_PASSWORD: "directus"
    volumes:
      - ./data/config:/var/directus/config
      - ./data/uploads:/var/directus/public/uploads
    links:
      - mysql:mysql
    networks:
      - netnet

networks:
 netnet:
于 2020-03-04T13:03:57.433 回答