Why does Docker container keeps restarting? ERROR: getaddrinfo EAI_AGAIN

Why does Docker container keeps restarting? ERROR: getaddrinfo EAI_AGAIN

这是我的 docker-compose.yml 文件

version: "3"
services:

  outline:
    image: outlinewiki/outline:latest
    restart: always
    command: sh -c "yarn sequelize:migrate --env=production-ssl-disabled && yarn start --env=production-ssl-disabled"
    env_file: ./docker.env
    ports:
      - "3000:3000"
    depends_on:
      - postgres
      - redis

  redis:
    image: redis
    restart: always
    env_file: ./docker.env
    ports:
      - "6379:6379"
    volumes:
      - ./redis.conf:/redis.conf
    command: ["redis-server", "/redis.conf"]

  postgres:
    image: postgres
    restart: always
    env_file: ./docker.env
    ports:
      - "5432:5432"
    volumes:
      - database-data:/var/lib/postgresql/data

volumes:
  database-data:

docker ps 显示 redis 和 postgres 正常,我的大纲应用容器正在重启

outlinewiki/outline:latest   "docker-entrypoint.s…"   2 minutes ago   Restarting (1) 20 seconds ago

然后我决定检查日志

ERROR: getaddrinfo EAI_AGAIN outline-wiki-db

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run v1.22.18
$ sequelize db:migrate --env=production-ssl-disabled

Sequelize CLI [Node: 16.14.2, CLI: 6.3.0, ORM: 6.9.0]

Loaded configuration file "server/config/database.json".

我无法登录容器。

Docker 视察节目

"Path": "docker-entrypoint.sh",
"Args": [
    "sh",
    "-c",
    "yarn sequelize:migrate --env=production-ssl-disabled && yarn start --env=production-ssl-disabled"
],

为什么我会收到错误:getaddrinfo EAI_AGAIN?

基于与您有非常相似问题的topic,应用程序无法连接到数据库。

这只是一个大胆的猜测,但基于您在日志中的错误:

ERROR: getaddrinfo EAI_AGAIN outline-wiki-db

我假设您正在尝试使用 outline-wiki-db 名称连接到数据库,这在您的情况下是错误的。根据您的撰写,我认为它需要尝试连接到 postgres