Search or ask Docker

Get task logs

GET /tasks/{id}/logs — Docker Engine API 1.57.

View Markdown
GET/tasks/{id}/logs

Get stdout and stderr logs from a task. See also /containers/{id}/logs.

Note: This endpoint works only for services with the local, json-file or journald logging drivers.

Connection and access

API connection and authentication guidance

/v1.57

No HTTP authentication requirement is declared for this operation. Transport access controls can still apply.

Parameters

id path Required

ID of the task

Type: string

All schema constraints and annotations
{
  "type": "string"
}

details query

Show task context and extra details provided to logs.

Type: boolean

All schema constraints and annotations
{
  "default": false,
  "type": "boolean"
}

follow query

Keep connection after returning logs.

Type: boolean

All schema constraints and annotations
{
  "default": false,
  "type": "boolean"
}

stdout query

Return logs from stdout

Type: boolean

All schema constraints and annotations
{
  "default": false,
  "type": "boolean"
}

stderr query

Return logs from stderr

Type: boolean

All schema constraints and annotations
{
  "default": false,
  "type": "boolean"
}

since query

Only return logs since this time, as a UNIX timestamp

Type: integer

All schema constraints and annotations
{
  "default": 0,
  "type": "integer"
}

timestamps query

Add timestamps to every log line

Type: boolean

All schema constraints and annotations
{
  "default": false,
  "type": "boolean"
}

tail query

Only return this number of log lines from the end of the logs. Specify as an integer or all to output all log lines.

Type: string

All schema constraints and annotations
{
  "default": "all",
  "type": "string"
}

Request and responses

Response 200

logs returned as a stream in response body

application/vnd.docker.multiplexed-stream

Type: string

All schema constraints and annotations
{
  "format": "binary",
  "type": "string"
}

Response 200

logs returned as a stream in response body

application/vnd.docker.raw-stream

Type: string

All schema constraints and annotations
{
  "format": "binary",
  "type": "string"
}

Response 404

no such task

application/json

Schema: ErrorResponse

Example

{
  "message": "No such task: c2ada9df5af8"
}

Response 500

server error

application/json

Schema: ErrorResponse

Schema example

{
  "message": "Something went wrong."
}

Response 503

node is not part of a swarm

application/json

Schema: ErrorResponse

Schema example

{
  "message": "Something went wrong."
}

Referenced schemas

#/components/schemas/ErrorResponse

Complete operation contract
{
  "description": "Get `stdout` and `stderr` logs from a task.\nSee also [`/containers/{id}/logs`](#operation/ContainerLogs).\n\n**Note**: This endpoint works only for services with the `local`,\n`json-file` or `journald` logging drivers.\n",
  "operationId": "TaskLogs",
  "parameters": [
    {
      "description": "ID of the task",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "description": "Show task context and extra details provided to logs.",
      "in": "query",
      "name": "details",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Keep connection after returning logs.",
      "in": "query",
      "name": "follow",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Return logs from `stdout`",
      "in": "query",
      "name": "stdout",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Return logs from `stderr`",
      "in": "query",
      "name": "stderr",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Only return logs since this time, as a UNIX timestamp",
      "in": "query",
      "name": "since",
      "schema": {
        "default": 0,
        "type": "integer"
      }
    },
    {
      "description": "Add timestamps to every log line",
      "in": "query",
      "name": "timestamps",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Only return this number of log lines from the end of the logs.\nSpecify as an integer or `all` to output all log lines.\n",
      "in": "query",
      "name": "tail",
      "schema": {
        "default": "all",
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/vnd.docker.multiplexed-stream": {
          "schema": {
            "format": "binary",
            "type": "string"
          }
        },
        "application/vnd.docker.raw-stream": {
          "schema": {
            "format": "binary",
            "type": "string"
          }
        }
      },
      "description": "logs returned as a stream in response body"
    },
    "404": {
      "content": {
        "application/json": {
          "example": {
            "message": "No such task: c2ada9df5af8"
          },
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "no such task"
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "server error"
    },
    "503": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "node is not part of a swarm"
    }
  },
  "summary": "Get task logs",
  "tags": [
    "Task"
  ]
}