v1

latestSwagger 2.02026-07-17108109409.0 KB
Service

Create a service

post/services/create

Headers

X-Registry-Authstring

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

Refer to the authentication section for details.

Request body

Namestring

Name of the service.

Labelsobject

User-defined key/value metadata.

Example request

{
  "Name": "web",
  "TaskTemplate": {
    "ContainerSpec": {
      "Image": "nginx:alpine",
      "Mounts": [
        {
          "ReadOnly": true,
          "Source": "web-data",
          "Target": "/usr/share/nginx/html",
          "Type": "volume",
          "VolumeOptions": {
            "DriverConfig": {},
            "Labels": {
              "com.example.something": "something-value"
            }
          }
        }
      ],
      "Hosts": [
        "10.10.10.10 host1",
        "ABCD:EF01:2345:6789:ABCD:EF01:2345:6789 host2"
      ],
      "User": "33",
      "DNSConfig": {
        "Nameservers": [
          "8.8.8.8"
        ],
        "Search": [
          "example.org"
        ],
        "Options": [
          "timeout:3"
        ]
      },
      "Secrets": [
        {
          "File": {
            "Name": "www.example.org.key",
            "UID": "33",
            "GID": "33",
            "Mode": 384
          },
          "SecretID": "fpjqlhnwb19zds35k8wn80lq9",
          "SecretName": "example_org_domain_key"
        }
      ]
    },
    "LogDriver": {
      "Name": "json-file",
      "Options": {
        "max-file": "3",
        "max-size": "10M"
      }
    },
    "Placement": {},
    "Resources": {
      "Limits": {
        "MemoryBytes": 104857600
      },
      "Reservations": {}
    },
    "RestartPolicy": {
      "Condition": "on-failure",
      "Delay": 10000000000,
      "MaxAttempts": 10
    }
  },
  "Mode": {
    "Replicated": {
      "Replicas": 4
    }
  },
  "UpdateConfig": {
    "Parallelism": 2,
    "Delay": 1000000000,
    "FailureAction": "pause",
    "Monitor": 15000000000,
    "MaxFailureRatio": 0.15
  },
  "RollbackConfig": {
    "Parallelism": 1,
    "Delay": 1000000000,
    "FailureAction": "pause",
    "Monitor": 15000000000,
    "MaxFailureRatio": 0.15
  },
  "EndpointSpec": {
    "Ports": [
      {
        "Protocol": "tcp",
        "PublishedPort": 8080,
        "TargetPort": 80
      }
    ]
  },
  "Labels": {
    "foo": "bar"
  }
}

Response

no error

IDstring

The ID of the created service.

Warningsstring[] nullable

Optional warning message.

FIXME(thaJeztah): this should have "omitempty" in the generated type.

Example response

{
  "ID": "ak7w3gjqoa3kuz8xcpnyy0pvl",
  "Warnings": [
    "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found"
  ]
}