2023年5月9日 星期二

Docker / docker compose cheatsheet

Background

Very often there are commands which are very useful for debugging and troubleshooting in docker and docker compose, this post is to document them down for future use.

  1. Gather health check command status information of specific container
    docker inspect --format "{{json .State.Health }}" anm11_log_server_1 | jq
    jq bash command is needed to install beforehand. Following results will be outputted

    {
      "Status": "healthy",
      "FailingStreak": 0,
      "Log": [
        {
          "Start": "2023-05-09T15:31:55.974151402+08:00",
          "End": "2023-05-09T15:31:56.180881836+08:00",
          "ExitCode": 0,
          "Output": ""
        },
        {
          "Start": "2023-05-09T15:32:56.185509821+08:00",
          "End": "2023-05-09T15:32:56.322503697+08:00",
          "ExitCode": 0,
          "Output": ""
        },
        {
          "Start": "2023-05-09T15:33:56.327354557+08:00",
          "End": "2023-05-09T15:33:56.506142901+08:00",
          "ExitCode": 0,
          "Output": ""
        },
        {
          "Start": "2023-05-09T15:37:16.863314985+08:00",
          "End": "2023-05-09T15:37:17.0210078+08:00",
          "ExitCode": 0,
          "Output": ""
        },
        {
          "Start": "2023-05-09T15:38:17.025502598+08:00",
          "End": "2023-05-09T15:38:17.155554148+08:00",
          "ExitCode": 0,
          "Output": ""
        }
      ]
    }