Rest Docker API v1.40获取容器日志

Rest Docker API v1.40获取容器日志,rest,docker,docker-api,Rest,Docker,Docker Api,我正在尝试使用Docker API检索容器日志 打开Docker州的API文档,获取容器日志;应该使用的语法是 /容器/{id}/日志 根据文件,可能有三种响应状态200、404和500 您可以看到下面的文档部分 responses: 200: description: | logs returned as a stream in response body. For the stream

我正在尝试使用Docker API检索容器日志

打开Docker州的API文档,获取容器日志;应该使用的语法是

/容器/{id}/日志

根据文件,可能有三种响应状态200404500

您可以看到下面的文档部分

responses:
        200:
          description: |
                  logs returned as a stream in response body.
                  For the stream format, [see the documentation for the attach endpoint](#operation/ContainerAttach).
                  Note that unlike the attach endpoint, the logs endpoint does not upgrade the connection and does not
                  set Content-Type.
          schema:
            type: "string"
            format: "binary"
        404:
          description: "no such container"
          schema:
            $ref: "#/definitions/ErrorResponse"
          examples:
            application/json:
              message: "No such container: c2ada9df5af8"
        500:
          description: "server error"
          schema:
            $ref: "#/definitions/ErrorResponse"
对我来说,有趣的是当我打电话时,我得到了400个错误,这在文档中是不存在的。 响应消息是这样的

{
    "message": "Bad parameters: you must choose at least one stream"
}

如何使用Docker API获取容器日志

通过发送
stdout
stderr
查询参数,指定从何处返回日志。例如:

curl --unix-socket /var/run/docker.sock http://localhost/containers/containerId/logs?stdout=true