v1

latestSwagger 2.02026-07-175684145.0 KB
Container

Create a container

post/containers/create

Query parameters

namestring

Assign the specified name to the container. Must match /?[a-zA-Z0-9_-]+.

Request body

Hostnamestring hostname

The hostname to use for the container, as a valid RFC 1123 hostname.

Domainnamestring

The domain name to use for the container.

Userstring

The user that commands are run as inside the container.

AttachStdinboolean

Whether to attach to stdin.

AttachStdoutboolean

Whether to attach to stdout.

AttachStderrboolean

Whether to attach to stderr.

DisableNetworkFilesboolean

Whether to generate the network files(/etc/hostname, /etc/hosts and /etc/resolv.conf) for container.

ExposedPortsobject

An object mapping ports to an empty object in the form:{<port>/<tcp|udp>: {}}

Ttyboolean

Attach standard streams to a TTY, including stdin if it is not closed.

OpenStdinboolean

Open stdin

StdinOnceboolean

Close stdin after one attached client disconnects

Envstring[]

A list of environment variables to set inside the container in the form ["VAR=value", ...]. A variable like "A=" means setting env A in container to be empty value. And a variable without = is removed from the environment, rather than to have an empty value.

Cmdstring[]

Command to run specified an array of strings.

ArgsEscapedboolean

Command is already escaped (Windows only)

Imagestring required

The name of the image to use when creating the container

Volumesobject

An object mapping mount point paths inside the container to empty objects.

WorkingDirstring

The working directory for commands to run in.

Entrypointstring[]

The entry point for the container as a string or an array of strings. If the array consists of exactly one empty string ([""]) then the entry point is reset to system default.

NetworkDisabledboolean

Disable networking for the container.

MacAddressstring

MAC address of the container.

OnBuildstring[]

ONBUILD metadata that were defined.

Labelsobject

User-defined key/value metadata.

StopSignalstring

Signal to stop a container as a string or unsigned integer.

StopTimeoutinteger

Timeout to stop a container in seconds.

Shellstring[]

Shell for when RUN, CMD, and ENTRYPOINT uses a shell.

Richboolean

Whether to start container in rich container mode. (default false)

RichMode'dumb-init' | 'sbin-init' | 'systemd'

Choose one rich container mode.(default dumb-init)

InitScriptstring

Initial script executed in container. The script will be executed before entrypoint or command

DiskQuotaobject nullable

Set disk quota for container. Key is the dir in container. Value is disk quota size for the dir. / means rootfs dir in container. .* includes rootfs dir and all volume dir.

SpecAnnotationobject

annotations send to runtime spec.

QuotaIDstring

Set disk quota by specified quota id. If QuotaID <= 0, it means pouchd should allocate a unique quota id by sequence automatically. By default, a quota ID is mapped to only one container. And one quota ID can include several mountpoint.

NetPriorityinteger

net priority.

SpecificIDstring

Create container with given id. MinLength: 64 MaxLength: 64 The characters of given id should be in 0123456789abcdef. By default, given id is unnecessary.

Snapshotterstring

The snapshotter container choose, can be different with default snapshotter. The Field only set through hook plugin.

Example request

{
  "HostConfig": {
    "PortBindings": {
      "443/tcp": [
        {
          "HostIp": "127.0.0.1",
          "HostPort": "4443"
        }
      ],
      "80/tcp": [
        {
          "HostIp": "0.0.0.0",
          "HostPort": "80"
        },
        {
          "HostIp": "0.0.0.0",
          "HostPort": "8080"
        }
      ],
      "80/udp": [
        {
          "HostIp": "0.0.0.0",
          "HostPort": "80"
        }
      ],
      "2377/tcp": null
    },
    "CpusetCpus": "0-3",
    "Devices": [
      {
        "PathOnHost": "/dev/deviceName",
        "PathInContainer": "/dev/deviceName",
        "CgroupPermissions": "mrw"
      }
    ],
    "DeviceCgroupRules": [
      "c 13:* rwm"
    ],
    "NvidiaConfig": {
      "NvidiaVisibleDevices": "Possible values.\n0,1,2, GPU-fef8089b …: a comma-separated list of GPU UUID(s) or index(es).\nall: all GPUs will be accessible, this is the default value in our container images.\nnone: no GPU will be accessible, but driver capabilities will be enabled.\n",
      "NvidiaDriverCapabilities": "Possible values\ncompute,video, graphics,utility …: a comma-separated list of driver features the container needs.\nall: enable all available driver capabilities.\n"
    }
  }
}

Response

Container created successfully

Idstring required

The ID of the created container

Namestring

The name of the created container

Warningsstring[] required

Warnings encountered when creating the container