日常忘记笔记 2024-03-15 14:29 采纳率: 0%
浏览 50

tried to kill container, but did not receive an exit event

tried to kill container, but did not receive an exit event

我尝试过以下方法,包括重启docker 都无法成功停掉这个容器,它一直处于重启的状态,

容器

CONTAINER IDIMAGECOMMANDCREATEDSTATUSNAMES
0a0df1b47044postgres:11.6-alpine"docker-entrypoint.s…"21 months agoRestarting (1) 3 months agocontainer_database_1

查看日志

PostgreSQL Database directory appears to contain a database; Skipping initialization

2022-06-11 06:38:40.487 UTC [1] FATAL:  database files are incompatible with server
2022-06-11 06:38:40.487 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 14, which is not compatible with this version 11.6.

更新尝试

  • docker-compose up -d
    Creating network "container_default" with the default driver
    Pulling database (postgres:)...
    latest: Pulling from library/postgres
    8a1e25ce7c4f: Pull complete
    002317ed8722: Pull complete
    c223965bd9a8: Pull complete
    847682431a68: Pull complete
    8d29ba654727: Pull complete
    fd133663e42b: Pull complete
    13de11c6ecda: Pull complete
    45bb35744214: Pull complete
    d4082e63ce2c: Pull complete
    269f33c511c1: Pull complete
    7cbaf3c85093: Pull complete
    f1c82efa0dcd: Pull complete
    e9d0d3c40657: Pull complete
    68bf5c580643: Pull complete
    Digest: sha256:6b841c8f6a819884207402f1209a8116844365df15fca8cf556fc54a24c70800
    Status: Downloaded newer image for postgres:latest
    Recreating container_database_1 ... error
    ERROR: for container_database_1  cannot stop container: 0a0df1b470443e65cbf8dcb35f735445c969a0c52957804e4d69db9a5be2e357: tried to kill container, but did not receive an exit event
    ERROR: for database  cannot stop container: 0a0df1b470443e65cbf8dcb35f735445c969a0c52957804e4d69db9a5be2e357: tried to kill container, but did not receive an exit event
    ERROR: Encountered errors while bringing up the project.
    

    操作尝试

  • docker stop 0a0df1b47044
    • 结果:
      Error response from daemon: cannot stop container: 0a0df1b47044: tried to kill container, but did not receive an exit event
  • docker kill 0a0df1b47044
    • 结果:
      Error response from daemon: Cannot kill container: 0a0df1b47044: tried to kill container, but did not receive an exit event
  • docker-compose stop
    • 结果:
      Stopping container_database_1 ... error
      ERROR: for container_database_1 cannot stop container: 0a0df1b470443e65cbf8dcb35f735445c969a0c52957804e4d69db9a5be2e357: tried to kill container, but did not receive an exit event
  • docker-compose down
    • 结果:
      Stopping container_database_1 ... error
      ERROR: for container_database_1 cannot stop container: 0a0df1b470443e65cbf8dcb35f735445c969a0c52957804e4d69db9a5be2e357: tried to kill container, but did not receive an exit event
      Removing network container_default
  • docker kill -s SIGKILL 0a0df1b47044
    • 结果:
      Error response from daemon: Cannot kill container: 0a0df1b47044: tried to kill container, but did not receive an exit event
  • 写回答

2条回答 默认 最新

  • 专家-赤兔[在线] 全栈领域优质创作者 2024-03-15 14:29
    关注

    引自免费微信小程序:皆我百晓生

    针对你遇到的问题,容器无法正常停止并一直处于重启状态,可能是因为容器内部的PostgreSQL服务在启动时由于数据库版本不兼容而未能成功运行,导致容器无法正常退出。以下是解决这个问题的步骤:

    1. 强制删除容器: 由于常规方法无法停止该容器,可以尝试使用docker container rm -f <container-id>命令强制删除它。将 <container-id> 替换为你的容器ID(在你的例子中是 0a0df1b47044)。

      docker container rm -f 0a0df1b47044
      
    2. 检查卷数据兼容性: 容器内的数据库文件是在 PostgreSQL 版本 14 下创建的,与你现在试图使用的镜像版本 11.6 不兼容。你需要决定如何处理这些数据:

      a) 如果你可以丢失这些数据或者有备份,可以直接重新创建一个新的容器而不挂载旧的数据卷。

      b) 如果需要保留数据,请先备份数据卷,然后升级到与数据兼容的 PostgreSQL 镜像版本(即 PostgreSQL 14 或更高版本)。备份数据可以通过以下命令完成(假设数据卷名为 pgdata):

      docker run --rm -v container_database_1_data:/var/lib/postgresql/data postgres:14-alpine \
          sh -c "pg_dumpall -U your_username > dump.sql"
      

      然后使用新版本的 PostgreSQL 镜像重建容器,并挂载回之前备份的数据卷。

    3. 重建容器: 使用正确的镜像版本和配置重建容器,例如:

      docker-compose up -d database
      

      (确保在你的 docker-compose.yml 文件中,数据库服务已更新为正确的镜像版本)

    4. 验证容器状态: 重建容器后,用 docker psdocker-compose ps 命令检查新容器是否按预期启动且运行状态正确。

    通过以上步骤应该能够解决当前问题。但请务必谨慎操作,特别是在处理数据库数据时,以防数据丢失或破坏。

    评论 编辑记录

报告相同问题?

问题事件

  • 专家修改了标签 3月15日
  • 创建了问题 3月15日

悬赏问题

  • ¥15 程序实在不会写,要秃了
  • ¥15 pycharm导入不了自己的包
  • ¥15 C#.net通过内网url地址获取文件并下载问题,浏览器postman可以正常下载,用程序不行
  • ¥15 本人本科机械,目前研一。没有深度学习基础,目前对研究生课题一片迷茫,请教各位!
  • ¥15 关于R语言单因素与多因素线性回归的平均值
  • ¥15 服务器清除BIOS之后引导不了
  • ¥15 CPLEX用OPL编写的混合整数线性优化问题。
  • ¥15 可以用EasyConnect连接实验室内网,但无法连接内网才能访问的服务器,为什么?
  • ¥15 前端预览docx文件,文件从后端传送过来。
  • ¥15 层次聚类和蛋白质相似度