# Update a service


[API catalog](/reference/api/) · [Docker Engine overview](/reference/api/engine/version/v1.57/) · [Product manual](https://docs.docker.com/engine/) · [OpenAPI specification](/reference/api/engine/version/v1.57.yaml)

API version: 1.57





`POST /services/{id}/update`



## Connection and access

[API connection and authentication guidance](/reference/api/engine/version/v1.57/#connection)

`X-Registry-Auth` delegates registry credentials and does not authenticate the daemon caller.


Server: `/v1.57`

Effective security: alternatives are OR; schemes within an alternative are AND. An empty array declares no HTTP authentication requirement.

```json
null
```

## Example request

Replace placeholders and provide the required credentials or request body.

```console
curl \
  --request POST \
  --unix-socket "${DOCKER_SOCKET:-/var/run/docker.sock}" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data-binary @request-body \
  'http://localhost/v1.57/services/<ID>/update?version=%3CVERSION%3E'
```


Prepare request-body using the selected media type and schema.


## Parameters

### id

Location: path. Required: yes.

ID or name of service.

```json
{
  "description": "ID or name of service.",
  "in": "path",
  "name": "id",
  "pointer": "/paths/~1services~1{id}~1update/post/parameters/0",
  "required": true,
  "schema": {
    "type": "string"
  }
}
```

### version

Location: query. Required: yes.

The version number of the service object being updated. This is
required to avoid conflicting writes.
This version number should be the value as currently set on the
service *before* the update. You can find the current version by
calling `GET /services/{id}`


```json
{
  "description": "The version number of the service object being updated. This is\nrequired to avoid conflicting writes.\nThis version number should be the value as currently set on the\nservice *before* the update. You can find the current version by\ncalling `GET /services/{id}`\n",
  "in": "query",
  "name": "version",
  "pointer": "/paths/~1services~1{id}~1update/post/parameters/1",
  "required": true,
  "schema": {
    "type": "integer"
  }
}
```

### registryAuthFrom

Location: query. Required: no.

If the `X-Registry-Auth` header is not specified, this parameter
indicates where to find registry authorization credentials.


```json
{
  "description": "If the `X-Registry-Auth` header is not specified, this parameter\nindicates where to find registry authorization credentials.\n",
  "in": "query",
  "name": "registryAuthFrom",
  "pointer": "/paths/~1services~1{id}~1update/post/parameters/2",
  "schema": {
    "default": "spec",
    "enum": [
      "spec",
      "previous-spec"
    ],
    "type": "string"
  }
}
```

### rollback

Location: query. Required: no.

Set to this parameter to `previous` to cause a server-side rollback
to the previous service spec. The supplied spec will be ignored in
this case.


```json
{
  "description": "Set to this parameter to `previous` to cause a server-side rollback\nto the previous service spec. The supplied spec will be ignored in\nthis case.\n",
  "in": "query",
  "name": "rollback",
  "pointer": "/paths/~1services~1{id}~1update/post/parameters/3",
  "schema": {
    "type": "string"
  }
}
```

### X-Registry-Auth

Location: header. Required: no.

A base64url-encoded auth configuration for pulling from private
registries.

Refer to the [authentication section](/reference/api/engine/version/v1.57/#authentication) for
details.


```json
{
  "description": "A base64url-encoded auth configuration for pulling from private\nregistries.\n\nRefer to the [authentication section](#section/Authentication) for\ndetails.\n",
  "in": "header",
  "name": "X-Registry-Auth",
  "pointer": "/paths/~1services~1{id}~1update/post/parameters/4",
  "schema": {
    "type": "string"
  }
}
```

## Request and responses

### Request  application/json




Schema:

```json
{
  "allOf": [
    {
      "$ref": "#/components/schemas/ServiceSpec"
    },
    {
      "example": {
        "EndpointSpec": {
          "Mode": "vip"
        },
        "Mode": {
          "Replicated": {
            "Replicas": 1
          }
        },
        "Name": "top",
        "RollbackConfig": {
          "Delay": 1000000000,
          "FailureAction": "pause",
          "MaxFailureRatio": 0.15,
          "Monitor": 15000000000,
          "Parallelism": 1
        },
        "TaskTemplate": {
          "ContainerSpec": {
            "Args": [
              "top"
            ],
            "Image": "busybox",
            "OomScoreAdj": 0
          },
          "ForceUpdate": 0,
          "Placement": {},
          "Resources": {
            "Limits": {},
            "Reservations": {}
          },
          "RestartPolicy": {
            "Condition": "any",
            "MaxAttempts": 0
          }
        },
        "UpdateConfig": {
          "Delay": 1000000000,
          "FailureAction": "pause",
          "MaxFailureRatio": 0.15,
          "Monitor": 15000000000,
          "Parallelism": 2
        }
      },
      "type": "object"
    }
  ]
}
```










### Response 200 application/json

no error


Schema:

```json
{
  "$ref": "#/components/schemas/ServiceUpdateResponse"
}
```









Schema example:
```json
{
  "Warnings": [
    "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found"
  ]
}
```


### Response 400 application/json

bad parameter


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


### Response 404 application/json

no such service


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


### Response 500 application/json

server error


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


### Response 503 application/json

node is not part of a swarm


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


## Complete operation contract

```json
{
  "operationId": "ServiceUpdate",
  "parameters": [
    {
      "description": "ID or name of service.",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "description": "The version number of the service object being updated. This is\nrequired to avoid conflicting writes.\nThis version number should be the value as currently set on the\nservice *before* the update. You can find the current version by\ncalling `GET /services/{id}`\n",
      "in": "query",
      "name": "version",
      "required": true,
      "schema": {
        "type": "integer"
      }
    },
    {
      "description": "If the `X-Registry-Auth` header is not specified, this parameter\nindicates where to find registry authorization credentials.\n",
      "in": "query",
      "name": "registryAuthFrom",
      "schema": {
        "default": "spec",
        "enum": [
          "spec",
          "previous-spec"
        ],
        "type": "string"
      }
    },
    {
      "description": "Set to this parameter to `previous` to cause a server-side rollback\nto the previous service spec. The supplied spec will be ignored in\nthis case.\n",
      "in": "query",
      "name": "rollback",
      "schema": {
        "type": "string"
      }
    },
    {
      "description": "A base64url-encoded auth configuration for pulling from private\nregistries.\n\nRefer to the [authentication section](#section/Authentication) for\ndetails.\n",
      "in": "header",
      "name": "X-Registry-Auth",
      "schema": {
        "type": "string"
      }
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "allOf": [
            {
              "$ref": "#/components/schemas/ServiceSpec"
            },
            {
              "example": {
                "EndpointSpec": {
                  "Mode": "vip"
                },
                "Mode": {
                  "Replicated": {
                    "Replicas": 1
                  }
                },
                "Name": "top",
                "RollbackConfig": {
                  "Delay": 1000000000,
                  "FailureAction": "pause",
                  "MaxFailureRatio": 0.15,
                  "Monitor": 15000000000,
                  "Parallelism": 1
                },
                "TaskTemplate": {
                  "ContainerSpec": {
                    "Args": [
                      "top"
                    ],
                    "Image": "busybox",
                    "OomScoreAdj": 0
                  },
                  "ForceUpdate": 0,
                  "Placement": {},
                  "Resources": {
                    "Limits": {},
                    "Reservations": {}
                  },
                  "RestartPolicy": {
                    "Condition": "any",
                    "MaxAttempts": 0
                  }
                },
                "UpdateConfig": {
                  "Delay": 1000000000,
                  "FailureAction": "pause",
                  "MaxFailureRatio": 0.15,
                  "Monitor": 15000000000,
                  "Parallelism": 2
                }
              },
              "type": "object"
            }
          ]
        }
      }
    },
    "required": true,
    "x-codegen-request-body-name": "body"
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ServiceUpdateResponse"
          }
        }
      },
      "description": "no error"
    },
    "400": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "bad parameter"
    },
    "404": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "no such service"
    },
    "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": "Update a service",
  "tags": [
    "Service"
  ]
}
```

## Referenced schemas

- [#/components/schemas/ErrorResponse](/reference/api/engine/version/v1.57/schemas/ErrorResponse/)

- [#/components/schemas/ServiceSpec](/reference/api/engine/version/v1.57/schemas/ServiceSpec/)

- [#/components/schemas/ServiceUpdateResponse](/reference/api/engine/version/v1.57/schemas/ServiceUpdateResponse/)




