Create a service
/v1.33
/v1.33
/v1.33
/v1.33
POST
/services/create
Service
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST '/v1.33/services/create' \
--header 'Content-Type: application/json' \
--data-raw '{
"EndpointSpec": {
"Mode": "vip",
"Ports": [
{
"Name": "string",
"Protocol": "tcp",
"PublishedPort": 8080,
"TargetPort": 80
}
]
},
"Labels": {
"property1": "string",
"property2": "string",
"foo": "bar"
},
"Mode": {
"Global": {},
"Replicated": {
"Replicas": 4
}
},
"Name": "web",
"Networks": [
{
"Aliases": [
"string"
],
"Target": "string"
}
],
"RollbackConfig": {
"Delay": 1000000000,
"FailureAction": "pause",
"MaxFailureRatio": 0.15,
"Monitor": 15000000000,
"Order": "stop-first",
"Parallelism": 1
},
"TaskTemplate": {
"ContainerSpec": {
"Args": [
"string"
],
"Command": [
"string"
],
"Configs": [
{
"ConfigID": "string",
"ConfigName": "string",
"File": {
"GID": "string",
"Mode": 0,
"Name": "string",
"UID": "string"
}
}
],
"DNSConfig": {
"Nameservers": [
"8.8.8.8"
],
"Options": [
"timeout:3"
],
"Search": [
"example.org"
]
},
"Dir": "string",
"Env": [
"string"
],
"Groups": [
"string"
],
"HealthCheck": {
"Interval": 0,
"Retries": 0,
"StartPeriod": 0,
"Test": [
"string"
],
"Timeout": 0
},
"Hostname": "string",
"Hosts": [
"10.10.10.10 host1",
"ABCD:EF01:2345:6789:ABCD:EF01:2345:6789 host2"
],
"Image": "nginx:alpine",
"Labels": {
"property1": "string",
"property2": "string"
},
"Mounts": [
{
"BindOptions": {
"Propagation": "private"
},
"Consistency": "string",
"ReadOnly": true,
"Source": "web-data",
"Target": "/usr/share/nginx/html",
"TmpfsOptions": {
"Mode": 0,
"SizeBytes": 0
},
"Type": "volume",
"VolumeOptions": {
"DriverConfig": {
"Name": "string",
"Options": {
"property1": "string",
"property2": "string"
}
},
"Labels": {
"property1": "string",
"property2": "string",
"com.example.something": "something-value"
},
"NoCopy": false
}
}
],
"OpenStdin": true,
"Privileges": {
"CredentialSpec": {
"File": "string",
"Registry": "string"
},
"SELinuxContext": {
"Disable": true,
"Level": "string",
"Role": "string",
"Type": "string",
"User": "string"
}
},
"ReadOnly": true,
"Secrets": [
{
"File": {
"GID": "33",
"Mode": 384,
"Name": "www.example.org.key",
"UID": "33"
},
"SecretID": "fpjqlhnwb19zds35k8wn80lq9",
"SecretName": "example_org_domain_key"
}
],
"StopGracePeriod": 0,
"StopSignal": "string",
"TTY": true,
"User": "33"
},
"ForceUpdate": 0,
"LogDriver": {
"Name": "json-file",
"Options": {
"property1": "string",
"property2": "string",
"max-file": "3",
"max-size": "10M"
}
},
"Networks": [
{
"Aliases": [
"string"
],
"Target": "string"
}
],
"Placement": {
"Constraints": [
"node.hostname!=node3.corp.example.com",
"node.role!=manager",
"node.labels.type==production"
],
"Platforms": [
{
"Architecture": "x86_64",
"OS": "linux"
}
],
"Preferences": [
{
"Spread": {
"SpreadDescriptor": "node.labels.datacenter"
}
},
{
"Spread": {
"SpreadDescriptor": "node.labels.rack"
}
}
]
},
"PluginSpec": {
"Disabled": true,
"Name": "string",
"PluginPrivilege": [
{
"Description": "string",
"Name": "string",
"Value": [
"string"
]
}
],
"Remote": "string"
},
"Resources": {
"Limits": {
"GenericResources": [
{
"DiscreteResourceSpec": {
"Kind": "SSD",
"Value": 3
}
},
{
"NamedResourceSpec": {
"Kind": "GPU",
"Value": "UUID1"
}
},
{
"NamedResourceSpec": {
"Kind": "GPU",
"Value": "UUID2"
}
}
],
"MemoryBytes": 104857600,
"NanoCPUs": 4000000000
},
"Reservation": {
"GenericResources": [
{
"DiscreteResourceSpec": {
"Kind": "SSD",
"Value": 3
}
},
{
"NamedResourceSpec": {
"Kind": "GPU",
"Value": "UUID1"
}
},
{
"NamedResourceSpec": {
"Kind": "GPU",
"Value": "UUID2"
}
}
],
"MemoryBytes": 8272408576,
"NanoCPUs": 4000000000
},
"Reservations": {}
},
"RestartPolicy": {
"Condition": "on-failure",
"Delay": 10000000000,
"MaxAttempts": 10,
"Window": 0
},
"Runtime": "string"
},
"UpdateConfig": {
"Delay": 1000000000,
"FailureAction": "pause",
"MaxFailureRatio": 0.15,
"Monitor": 15000000000,
"Order": "stop-first",
"Parallelism": 2
}
}'
Response Response Example
201 - Example 1
{
"ID": "ak7w3gjqoa3kuz8xcpnyy0pvl",
"Warning": "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found"
}
Request
Header Params
X-Registry-Auth
stringÂ
optional
Body Params application/json
Responses
Modified at 2022-09-10 17:56:07