Update a service Run in API Explorer
Headers
-
A base64url-encoded auth configuration for pulling from private registries.
Refer to the authentication section for details.
Query parameters
-
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}
-
If the
X-Registry-Auth
header is not specified, this parameter indicates where to find registry authorization credentials.Values are
spec
orprevious-spec
. Default value isspec
. -
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.
Body
Required
-
Name of the service.
-
User-defined key/value metadata.
-
User modifiable task configuration.
-
Scheduling mode for the service.
-
Specification for the update strategy of the service.
-
Specification for the rollback strategy of the service.
-
Specifies which networks the service should attach to.
Deprecated: This field is deprecated since v1.44. The Networks field in TaskSpec should be used instead.
Specifies how a service should be attached to a particular network.
-
Properties that can be configured to access and load balance a service.
curl \
--request POST 'http://api.example.com/v1.49/services/{id}/update?version=42' \
--header "Content-Type: application/json" \
--header "X-Registry-Auth: string" \
--data '{"Name":"string","Labels":{"additionalProperty1":"string","additionalProperty2":"string"},"TaskTemplate":{"PluginSpec":{"Name":"string","Remote":"string","Disabled":true,"PluginPrivilege":[{"Name":"network","Description":"string","Value":["host"]}]},"ContainerSpec":{"Image":"string","Labels":{"additionalProperty1":"string","additionalProperty2":"string"},"Command":["string"],"Args":["string"],"Hostname":"string","Env":["string"],"Dir":"string","User":"string","Groups":["string"],"Privileges":{"CredentialSpec":{"Config":"0bt9dmxjvjiqermk6xrop3ekq","File":"spec.json","Registry":"string"},"SELinuxContext":{"Disable":true,"User":"string","Role":"string","Type":"string","Level":"string"},"Seccomp":{"Mode":"default","Profile":"string"},"AppArmor":{"Mode":"default"},"NoNewPrivileges":true},"TTY":true,"OpenStdin":true,"ReadOnly":true,"Mounts":[{"Target":"string","Source":"string","Type":"bind","ReadOnly":true,"Consistency":"string","BindOptions":{"Propagation":"private","NonRecursive":false,"CreateMountpoint":false,"ReadOnlyNonRecursive":false,"ReadOnlyForceRecursive":false},"VolumeOptions":{"NoCopy":false,"Labels":{"additionalProperty1":"string","additionalProperty2":"string"},"DriverConfig":{"Name":"string","Options":{"additionalProperty1":"string","additionalProperty2":"string"}},"Subpath":"dir-inside-volume/subdirectory"},"ImageOptions":{"Subpath":"dir-inside-image/subdirectory"},"TmpfsOptions":{"SizeBytes":42,"Mode":42,"Options":[["noexec"]]}}],"StopSignal":"string","StopGracePeriod":42,"HealthCheck":{"Test":["string"],"Interval":42,"Timeout":42,"Retries":42,"StartPeriod":42,"StartInterval":42},"Hosts":["string"],"DNSConfig":{"Nameservers":["string"],"Search":["string"],"Options":["string"]},"Secrets":[{"File":{"Name":"string","UID":"string","GID":"string","Mode":42},"SecretID":"string","SecretName":"string"}],"OomScoreAdj":0,"Configs":[{"File":{"Name":"string","UID":"string","GID":"string","Mode":42},"Runtime":{},"ConfigID":"string","ConfigName":"string"}],"Isolation":"default","Init":true,"Sysctls":{"additionalProperty1":"string","additionalProperty2":"string"},"CapabilityAdd":["CAP_NET_RAW","CAP_SYS_ADMIN","CAP_SYS_CHROOT","CAP_SYSLOG"],"CapabilityDrop":["CAP_NET_RAW"],"Ulimits":[{"Name":"string","Soft":42,"Hard":42}]},"NetworkAttachmentSpec":{"ContainerID":"string"},"Resources":{"Limits":{"NanoCPUs":4000000000,"MemoryBytes":8272408576,"Pids":100},"Reservations":{"NanoCPUs":4000000000,"MemoryBytes":8272408576,"GenericResources":[{"DiscreteResourceSpec":{"Kind":"SSD","Value":3}},{"NamedResourceSpec":{"Kind":"GPU","Value":"UUID1"}},{"NamedResourceSpec":{"Kind":"GPU","Value":"UUID2"}}]}},"RestartPolicy":{"Condition":"none","Delay":42,"MaxAttempts":0,"Window":0},"Placement":{"Constraints":["node.hostname!=node3.corp.example.com","node.role!=manager","node.labels.type==production","node.platform.os==linux","node.platform.arch==x86_64"],"Preferences":[{"Spread":{"SpreadDescriptor":"node.labels.datacenter"}},{"Spread":{"SpreadDescriptor":"node.labels.rack"}}],"MaxReplicas":0,"Platforms":[{"Architecture":"x86_64","OS":"linux"}]},"ForceUpdate":42,"Runtime":"string","Networks":[{"Target":"string","Aliases":["string"],"DriverOpts":{"additionalProperty1":"string","additionalProperty2":"string"}}],"LogDriver":{"Name":"string","Options":{"additionalProperty1":"string","additionalProperty2":"string"}}},"Mode":{"Replicated":{"Replicas":42},"Global":{},"ReplicatedJob":{"MaxConcurrent":1,"TotalCompletions":42},"GlobalJob":{}},"UpdateConfig":{"Parallelism":42,"Delay":42,"FailureAction":"continue","Monitor":42,"MaxFailureRatio":0,"Order":"stop-first"},"RollbackConfig":{"Parallelism":42,"Delay":42,"FailureAction":"continue","Monitor":42,"MaxFailureRatio":0,"Order":"stop-first"},"Networks":[{"Target":"string","Aliases":["string"],"DriverOpts":{"additionalProperty1":"string","additionalProperty2":"string"}}],"EndpointSpec":{"Mode":"vip","Ports":[{"Name":"string","Protocol":"tcp","TargetPort":42,"PublishedPort":42,"PublishMode":"ingress"}]}}'
# Headers
X-Registry-Auth: string
# Payload
{
"Name": "string",
"Labels": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"TaskTemplate": {
"PluginSpec": {
"Name": "string",
"Remote": "string",
"Disabled": true,
"PluginPrivilege": [
{
"Name": "network",
"Description": "string",
"Value": [
"host"
]
}
]
},
"ContainerSpec": {
"Image": "string",
"Labels": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"Command": [
"string"
],
"Args": [
"string"
],
"Hostname": "string",
"Env": [
"string"
],
"Dir": "string",
"User": "string",
"Groups": [
"string"
],
"Privileges": {
"CredentialSpec": {
"Config": "0bt9dmxjvjiqermk6xrop3ekq",
"File": "spec.json",
"Registry": "string"
},
"SELinuxContext": {
"Disable": true,
"User": "string",
"Role": "string",
"Type": "string",
"Level": "string"
},
"Seccomp": {
"Mode": "default",
"Profile": "string"
},
"AppArmor": {
"Mode": "default"
},
"NoNewPrivileges": true
},
"TTY": true,
"OpenStdin": true,
"ReadOnly": true,
"Mounts": [
{
"Target": "string",
"Source": "string",
"Type": "bind",
"ReadOnly": true,
"Consistency": "string",
"BindOptions": {
"Propagation": "private",
"NonRecursive": false,
"CreateMountpoint": false,
"ReadOnlyNonRecursive": false,
"ReadOnlyForceRecursive": false
},
"VolumeOptions": {
"NoCopy": false,
"Labels": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"DriverConfig": {
"Name": "string",
"Options": {
"additionalProperty1": "string",
"additionalProperty2": "string"
}
},
"Subpath": "dir-inside-volume/subdirectory"
},
"ImageOptions": {
"Subpath": "dir-inside-image/subdirectory"
},
"TmpfsOptions": {
"SizeBytes": 42,
"Mode": 42,
"Options": [
[
"noexec"
]
]
}
}
],
"StopSignal": "string",
"StopGracePeriod": 42,
"HealthCheck": {
"Test": [
"string"
],
"Interval": 42,
"Timeout": 42,
"Retries": 42,
"StartPeriod": 42,
"StartInterval": 42
},
"Hosts": [
"string"
],
"DNSConfig": {
"Nameservers": [
"string"
],
"Search": [
"string"
],
"Options": [
"string"
]
},
"Secrets": [
{
"File": {
"Name": "string",
"UID": "string",
"GID": "string",
"Mode": 42
},
"SecretID": "string",
"SecretName": "string"
}
],
"OomScoreAdj": 0,
"Configs": [
{
"File": {
"Name": "string",
"UID": "string",
"GID": "string",
"Mode": 42
},
"Runtime": {},
"ConfigID": "string",
"ConfigName": "string"
}
],
"Isolation": "default",
"Init": true,
"Sysctls": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"CapabilityAdd": [
"CAP_NET_RAW",
"CAP_SYS_ADMIN",
"CAP_SYS_CHROOT",
"CAP_SYSLOG"
],
"CapabilityDrop": [
"CAP_NET_RAW"
],
"Ulimits": [
{
"Name": "string",
"Soft": 42,
"Hard": 42
}
]
},
"NetworkAttachmentSpec": {
"ContainerID": "string"
},
"Resources": {
"Limits": {
"NanoCPUs": 4000000000,
"MemoryBytes": 8272408576,
"Pids": 100
},
"Reservations": {
"NanoCPUs": 4000000000,
"MemoryBytes": 8272408576,
"GenericResources": [
{
"DiscreteResourceSpec": {
"Kind": "SSD",
"Value": 3
}
},
{
"NamedResourceSpec": {
"Kind": "GPU",
"Value": "UUID1"
}
},
{
"NamedResourceSpec": {
"Kind": "GPU",
"Value": "UUID2"
}
}
]
}
},
"RestartPolicy": {
"Condition": "none",
"Delay": 42,
"MaxAttempts": 0,
"Window": 0
},
"Placement": {
"Constraints": [
"node.hostname!=node3.corp.example.com",
"node.role!=manager",
"node.labels.type==production",
"node.platform.os==linux",
"node.platform.arch==x86_64"
],
"Preferences": [
{
"Spread": {
"SpreadDescriptor": "node.labels.datacenter"
}
},
{
"Spread": {
"SpreadDescriptor": "node.labels.rack"
}
}
],
"MaxReplicas": 0,
"Platforms": [
{
"Architecture": "x86_64",
"OS": "linux"
}
]
},
"ForceUpdate": 42,
"Runtime": "string",
"Networks": [
{
"Target": "string",
"Aliases": [
"string"
],
"DriverOpts": {
"additionalProperty1": "string",
"additionalProperty2": "string"
}
}
],
"LogDriver": {
"Name": "string",
"Options": {
"additionalProperty1": "string",
"additionalProperty2": "string"
}
}
},
"Mode": {
"Replicated": {
"Replicas": 42
},
"Global": {},
"ReplicatedJob": {
"MaxConcurrent": 1,
"TotalCompletions": 42
},
"GlobalJob": {}
},
"UpdateConfig": {
"Parallelism": 42,
"Delay": 42,
"FailureAction": "continue",
"Monitor": 42,
"MaxFailureRatio": 0,
"Order": "stop-first"
},
"RollbackConfig": {
"Parallelism": 42,
"Delay": 42,
"FailureAction": "continue",
"Monitor": 42,
"MaxFailureRatio": 0,
"Order": "stop-first"
},
"Networks": [
{
"Target": "string",
"Aliases": [
"string"
],
"DriverOpts": {
"additionalProperty1": "string",
"additionalProperty2": "string"
}
}
],
"EndpointSpec": {
"Mode": "vip",
"Ports": [
{
"Name": "string",
"Protocol": "tcp",
"TargetPort": 42,
"PublishedPort": 42,
"PublishMode": "ingress"
}
]
}
}
{
"Warnings": [
"unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found"
]
}
{
"Warnings": [
"unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found"
]
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}