【问题标题】:How to show the health of a docker container in IntelliJ?如何在 IntelliJ 中显示 docker 容器的运行状况?
【发布时间】:2019-08-07 14:52:36
【问题描述】:

我有一个docker-compose.yml 文件,我正在使用 IntellJ 2019.2 来运行该服务,它运行良好。

我想通过 IntelliJ 查看容器的运行状况(启动、运行状况良好的 .etc)。
但是我找到的唯一方法是right-click on the container > inspect > search the state in the json,这不是很方便。

有没有人知道另一种轻松显示容器健康状态的方法?

检测出来的json

[...]
"State": {
        "Status": "running",
        "Health": {
          "Status": "healthy", // that's what I want
[...]

docker-compose 文件

version: '3.4'

services:

  application:
    image: com.my.company/image
    depends_on: 
      - database
    build: ./build
    ports:
      - "8080:8080"
    networks:
      - app_network
    healthcheck:
      test: ["CMD", "curl", "-sSf", "http://localhost:8080/app"]
      start_period: 30s

【问题讨论】:

    标签: docker intellij-idea docker-compose health-monitoring


    【解决方案1】:

    有一个显示健康状态的功能请求:https://youtrack.jetbrains.com/issue/IDEA-214513

    【讨论】:

    • 嗯,功能请求处于非活动状态,我认为我们不会看到它。但是作者说What happens instead? They look the same, but mouseover shows "unhealthy" status - 不知道鼠标悬停,还是比我之前的方法好
    【解决方案2】:

    最简单的方法是在终端(操作系统或 IntelliJ IDEA)中执行以下命令:

    docker ps --format "table {{.ID}}\t{{.Names}}\t{{.RunningFor}}\t{{.Status}}"
    

    这里只是添加了一些格式,大概

    docker ps -a
    

    会绰绰有余。

    【讨论】:

    • 谢谢,但我知道 cli,但我正在寻找 IDE 中的内置功能。
    猜你喜欢
    • 2015-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-19
    相关资源
    最近更新 更多