v1

latestOpenAPI 3.0.02026-07-1410578280.2 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

ArgsEscapedboolean

Command is already escaped (Windows only)

AttachStderrboolean

Whether to attach to stderr.

AttachStdinboolean

Whether to attach to stdin.

AttachStdoutboolean

Whether to attach to stdout.

Domainnamestring

The domain name to use for the container.

Envstring[]

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

ExposedPortsobject

An object mapping ports to an empty object in the form:

{"<port>/<tcp|udp>": {}}

Hostnamestring

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

Imagestring

The name of the image to use when creating the container

Labelsobject

User-defined key/value metadata.

MacAddressstring

MAC address of the container.

NetworkDisabledboolean

Disable networking for the container.

OnBuildstring[]

ONBUILD metadata that were defined in the image's Dockerfile.

OpenStdinboolean

Open stdin

Shellstring[]

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

StdinOnceboolean

Close stdin after one attached client disconnects

StopSignalstring

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

StopTimeoutinteger

Timeout to stop a container in seconds.

Ttyboolean

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

Userstring

The user that commands are run as inside the container.

WorkingDirstring

The working directory for commands to run in.

Example request

{
  "AttachStderr": true,
  "AttachStdin": false,
  "AttachStdout": true,
  "Cmd": [
    "date"
  ],
  "Domainname": "",
  "Entrypoint": "",
  "Env": [
    "FOO=bar",
    "BAZ=quux"
  ],
  "ExposedPorts": {
    "22/tcp": {}
  },
  "HostConfig": {
    "AutoRemove": true,
    "Binds": [
      "/tmp:/tmp"
    ],
    "BlkioDeviceReadBps": [
      {}
    ],
    "BlkioDeviceReadIOps": [
      {}
    ],
    "BlkioDeviceWriteBps": [
      {}
    ],
    "BlkioDeviceWriteIOps": [
      {}
    ],
    "BlkioWeight": 300,
    "BlkioWeightDevice": [
      {}
    ],
    "CapAdd": [
      "NET_ADMIN"
    ],
    "CapDrop": [
      "MKNOD"
    ],
    "CgroupParent": "",
    "CpuPercent": 80,
    "CpuPeriod": 100000,
    "CpuQuota": 50000,
    "CpuRealtimePeriod": 1000000,
    "CpuRealtimeRuntime": 10000,
    "CpuShares": 512,
    "CpusetCpus": "0,1",
    "CpusetMems": "0,1",
    "Devices": [],
    "Dns": [
      "8.8.8.8"
    ],
    "DnsOptions": [
      ""
    ],
    "DnsSearch": [
      ""
    ],
    "GroupAdd": [
      "newgroup"
    ],
    "KernelMemory": 0,
    "Links": [
      "redis3:redis"
    ],
    "LogConfig": {
      "Config": {},
      "Type": "json-file"
    },
    "MaximumIOBps": 0,
    "MaximumIOps": 0,
    "Memory": 0,
    "MemoryReservation": 0,
    "MemorySwap": 0,
    "MemorySwappiness": 60,
    "NanoCPUs": 500000,
    "NetworkMode": "bridge",
    "OomKillDisable": false,
    "OomScoreAdj": 500,
    "PidMode": "",
    "PidsLimit": -1,
    "PortBindings": {
      "22/tcp": [
        {
          "HostPort": "11022"
        }
      ]
    },
    "Privileged": false,
    "PublishAllPorts": false,
    "ReadonlyRootfs": false,
    "RestartPolicy": {
      "MaximumRetryCount": 0,
      "Name": ""
    },
    "SecurityOpt": [],
    "ShmSize": 67108864,
    "StorageOpt": {},
    "Ulimits": [
      {}
    ],
    "VolumeDriver": "",
    "VolumesFrom": [
      "parent",
      "other:ro"
    ]
  },
  "Hostname": "",
  "Image": "ubuntu",
  "Labels": {
    "com.example.license": "GPL",
    "com.example.vendor": "Acme",
    "com.example.version": "1.0"
  },
  "MacAddress": "12:34:56:78:9a:bc",
  "NetworkDisabled": false,
  "NetworkingConfig": {
    "EndpointsConfig": {
      "isolated_nw": {
        "Aliases": [
          "server_x",
          "server_y"
        ],
        "IPAMConfig": {
          "IPv4Address": "172.20.30.33",
          "IPv6Address": "2001:db8:abcd::3033",
          "LinkLocalIPs": [
            "169.254.34.68",
            "fe80::3468"
          ]
        },
        "Links": [
          "container_1",
          "container_2"
        ]
      }
    }
  },
  "OpenStdin": false,
  "StdinOnce": false,
  "StopSignal": "SIGTERM",
  "StopTimeout": 10,
  "Tty": false,
  "User": "",
  "Volumes": {
    "/volumes/data": {}
  },
  "WorkingDir": ""
}

Response

Container created successfully

Idstring required

The ID of the created container

Warningsstring[] required

Warnings encountered when creating the container