github.com/jogo/docker@v1.7.0-rc1/docs/sources/reference/api/docker_remote_api_v1.18.md (about)

     1  page_title: Remote API v1.18
     2  page_description: API Documentation for Docker
     3  page_keywords: API, Docker, rcli, REST, documentation
     4  
     5  # Docker Remote API v1.18
     6  
     7  ## 1. Brief introduction
     8  
     9   - The Remote API has replaced `rcli`.
    10   - The daemon listens on `unix:///var/run/docker.sock` but you can
    11     [Bind Docker to another host/port or a Unix socket](
    12     /articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket).
    13   - The API tends to be REST, but for some complex commands, like `attach`
    14     or `pull`, the HTTP connection is hijacked to transport `STDOUT`,
    15     `STDIN` and `STDERR`.
    16  
    17  # 2. Endpoints
    18  
    19  ## 2.1 Containers
    20  
    21  ### List containers
    22  
    23  `GET /containers/json`
    24  
    25  List containers
    26  
    27  **Example request**:
    28  
    29          GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
    30  
    31  **Example response**:
    32  
    33          HTTP/1.1 200 OK
    34          Content-Type: application/json
    35  
    36          [
    37               {
    38                       "Id": "8dfafdbc3a40",
    39                       "Image": "ubuntu:latest",
    40                       "Command": "echo 1",
    41                       "Created": 1367854155,
    42                       "Status": "Exit 0",
    43                       "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
    44                       "SizeRw": 12288,
    45                       "SizeRootFs": 0
    46               },
    47               {
    48                       "Id": "9cd87474be90",
    49                       "Image": "ubuntu:latest",
    50                       "Command": "echo 222222",
    51                       "Created": 1367854155,
    52                       "Status": "Exit 0",
    53                       "Ports": [],
    54                       "SizeRw": 12288,
    55                       "SizeRootFs": 0
    56               },
    57               {
    58                       "Id": "3176a2479c92",
    59                       "Image": "ubuntu:latest",
    60                       "Command": "echo 3333333333333333",
    61                       "Created": 1367854154,
    62                       "Status": "Exit 0",
    63                       "Ports":[],
    64                       "SizeRw":12288,
    65                       "SizeRootFs":0
    66               },
    67               {
    68                       "Id": "4cb07b47f9fb",
    69                       "Image": "ubuntu:latest",
    70                       "Command": "echo 444444444444444444444444444444444",
    71                       "Created": 1367854152,
    72                       "Status": "Exit 0",
    73                       "Ports": [],
    74                       "SizeRw": 12288,
    75                       "SizeRootFs": 0
    76               }
    77          ]
    78  
    79  Query Parameters:
    80  
    81  -   **all** – 1/True/true or 0/False/false, Show all containers.
    82          Only running containers are shown by default (i.e., this defaults to false)
    83  -   **limit** – Show `limit` last created
    84          containers, include non-running ones.
    85  -   **since** – Show only containers created since Id, include
    86          non-running ones.
    87  -   **before** – Show only containers created before Id, include
    88          non-running ones.
    89  -   **size** – 1/True/true or 0/False/false, Show the containers
    90          sizes
    91  -   **filters** - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters:
    92    -   exited=<int> -- containers with exit code of <int>
    93    -   status=(restarting|running|paused|exited)
    94    -   label=`key` or `key=value` of a container label
    95  
    96  Status Codes:
    97  
    98  -   **200** – no error
    99  -   **400** – bad parameter
   100  -   **500** – server error
   101  
   102  ### Create a container
   103  
   104  `POST /containers/create`
   105  
   106  Create a container
   107  
   108  **Example request**:
   109  
   110          POST /containers/create HTTP/1.1
   111          Content-Type: application/json
   112  
   113          {
   114               "Hostname": "",
   115               "Domainname": "",
   116               "User": "",
   117               "AttachStdin": false,
   118               "AttachStdout": true,
   119               "AttachStderr": true,
   120               "Tty": false,
   121               "OpenStdin": false,
   122               "StdinOnce": false,
   123               "Env": null,
   124               "Cmd": [
   125                       "date"
   126               ],
   127               "Entrypoint": "",
   128               "Image": "ubuntu",
   129               "Labels": {
   130                       "com.example.vendor": "Acme",
   131                       "com.example.license": "GPL",
   132                       "com.example.version": "1.0"
   133               },
   134               "Volumes": {
   135                       "/tmp": {}
   136               },
   137               "WorkingDir": "",
   138               "NetworkDisabled": false,
   139               "MacAddress": "12:34:56:78:9a:bc",
   140               "ExposedPorts": {
   141                       "22/tcp": {}
   142               },
   143               "HostConfig": {
   144                 "Binds": ["/tmp:/tmp"],
   145                 "Links": ["redis3:redis"],
   146                 "LxcConf": {"lxc.utsname":"docker"},
   147                 "Memory": 0,
   148                 "MemorySwap": 0,
   149                 "CpuShares": 512,
   150                 "CpusetCpus": "0,1",
   151                 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
   152                 "PublishAllPorts": false,
   153                 "Privileged": false,
   154                 "ReadonlyRootfs": false,
   155                 "Dns": ["8.8.8.8"],
   156                 "DnsSearch": [""],
   157                 "ExtraHosts": null,
   158                 "VolumesFrom": ["parent", "other:ro"],
   159                 "CapAdd": ["NET_ADMIN"],
   160                 "CapDrop": ["MKNOD"],
   161                 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
   162                 "NetworkMode": "bridge",
   163                 "Devices": [],
   164                 "Ulimits": [{}],
   165                 "LogConfig": { "Type": "json-file", Config: {} },
   166                 "SecurityOpt": [""],
   167                 "CgroupParent": ""
   168              }
   169          }
   170  
   171  **Example response**:
   172  
   173          HTTP/1.1 201 Created
   174          Content-Type: application/json
   175  
   176          {
   177               "Id":"e90e34656806"
   178               "Warnings":[]
   179          }
   180  
   181  Json Parameters:
   182  
   183  -   **Hostname** - A string value containing the desired hostname to use for the
   184        container.
   185  -   **Domainname** - A string value containing the desired domain name to use
   186        for the container.
   187  -   **User** - A string value containing the user to use inside the container.
   188  -   **Memory** - Memory limit in bytes.
   189  -   **MemorySwap**- Total memory limit (memory + swap); set `-1` to disable swap,
   190        always use this with `memory`, and make the value larger than `memory`.
   191  -   **CpuShares** - An integer value containing the CPU Shares for container
   192        (ie. the relative weight vs other containers).
   193  -   **Cpuset** - The same as CpusetCpus, but deprecated, please don't use.
   194  -   **CpusetCpus** - String value containing the cgroups CpusetCpus to use.
   195  -   **AttachStdin** - Boolean value, attaches to stdin.
   196  -   **AttachStdout** - Boolean value, attaches to stdout.
   197  -   **AttachStderr** - Boolean value, attaches to stderr.
   198  -   **Tty** - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.
   199  -   **OpenStdin** - Boolean value, opens stdin,
   200  -   **StdinOnce** - Boolean value, close stdin after the 1 attached client disconnects.
   201  -   **Env** - A list of environment variables in the form of `VAR=value`
   202  -   **Labels** - Adds a map of labels that to a container. To specify a map: `{"key":"value"[,"key2":"value2"]}`
   203  -   **Cmd** - Command to run specified as a string or an array of strings.
   204  -   **Entrypoint** - Set the entrypoint for the container a a string or an array
   205        of strings
   206  -   **Image** - String value containing the image name to use for the container
   207  -   **Volumes** – An object mapping mountpoint paths (strings) inside the
   208        container to empty objects.
   209  -   **WorkingDir** - A string value containing the working dir for commands to
   210        run in.
   211  -   **NetworkDisabled** - Boolean value, when true disables networking for the
   212        container
   213  -   **ExposedPorts** - An object mapping ports to an empty object in the form of:
   214        `"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
   215  -   **HostConfig**
   216      -   **Binds** – A list of volume bindings for this container. Each volume
   217              binding is a string of the form `container_path` (to create a new
   218              volume for the container), `host_path:container_path` (to bind-mount
   219              a host path into the container), or `host_path:container_path:ro`
   220              (to make the bind-mount read-only inside the container).
   221      -   **Links** - A list of links for the container. Each link entry should be
   222            in the form of `container_name:alias`.
   223      -   **LxcConf** - LXC specific configurations. These configurations will only
   224            work when using the `lxc` execution driver.
   225      -   **PortBindings** - A map of exposed container ports and the host port they
   226            should map to. It should be specified in the form
   227            `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
   228            Take note that `port` is specified as a string and not an integer value.
   229      -   **PublishAllPorts** - Allocates a random host port for all of a container's
   230            exposed ports. Specified as a boolean value.
   231      -   **Privileged** - Gives the container full access to the host. Specified as
   232            a boolean value.
   233      -   **ReadonlyRootfs** - Mount the container's root filesystem as read only.
   234            Specified as a boolean value.
   235      -   **Dns** - A list of dns servers for the container to use.
   236      -   **DnsSearch** - A list of DNS search domains
   237      -   **ExtraHosts** - A list of hostnames/IP mappings to be added to the
   238          container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
   239      -   **VolumesFrom** - A list of volumes to inherit from another container.
   240            Specified in the form `<container name>[:<ro|rw>]`
   241      -   **CapAdd** - A list of kernel capabilities to add to the container.
   242      -   **Capdrop** - A list of kernel capabilities to drop from the container.
   243      -   **RestartPolicy** – The behavior to apply when the container exits.  The
   244              value is an object with a `Name` property of either `"always"` to
   245              always restart or `"on-failure"` to restart only when the container
   246              exit code is non-zero.  If `on-failure` is used, `MaximumRetryCount`
   247              controls the number of times to retry before giving up.
   248              The default is not to restart. (optional)
   249              An ever increasing delay (double the previous delay, starting at 100mS)
   250              is added before each restart to prevent flooding the server.
   251      -   **NetworkMode** - Sets the networking mode for the container. Supported
   252            values are: `bridge`, `host`, and `container:<name|id>`
   253      -   **Devices** - A list of devices to add to the container specified in the
   254            form
   255            `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
   256      -   **Ulimits** - A list of ulimits to be set in the container, specified as
   257            `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
   258            `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard", 2048 }}`
   259      -   **SecurityOpt**: A list of string values to customize labels for MLS
   260          systems, such as SELinux.
   261      -   **LogConfig** - Log configuration for the container, specified as
   262            `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
   263            Available types: `json-file`, `syslog`, `none`.
   264            `json-file` logging driver.
   265      -   **CgroupParent** - Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
   266  
   267  Query Parameters:
   268  
   269  -   **name** – Assign the specified name to the container. Must
   270      match `/?[a-zA-Z0-9_-]+`.
   271  
   272  Status Codes:
   273  
   274  -   **201** – no error
   275  -   **404** – no such container
   276  -   **406** – impossible to attach (container not running)
   277  -   **500** – server error
   278  
   279  ### Inspect a container
   280  
   281  `GET /containers/(id)/json`
   282  
   283  Return low-level information on the container `id`
   284  
   285  
   286  **Example request**:
   287  
   288          GET /containers/4fa6e0f0c678/json HTTP/1.1
   289  
   290  **Example response**:
   291  
   292          HTTP/1.1 200 OK
   293          Content-Type: application/json
   294  
   295  	{
   296  		"AppArmorProfile": "",
   297  		"Args": [
   298  			"-c",
   299  			"exit 9"
   300  		],
   301  		"Config": {
   302  			"AttachStderr": true,
   303  			"AttachStdin": false,
   304  			"AttachStdout": true,
   305  			"Cmd": [
   306  				"/bin/sh",
   307  				"-c",
   308  				"exit 9"
   309  			],
   310  			"Domainname": "",
   311  			"Entrypoint": null,
   312  			"Env": [
   313  				"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   314  			],
   315  			"ExposedPorts": null,
   316  			"Hostname": "ba033ac44011",
   317  			"Image": "ubuntu",
   318  			"Labels": {
   319  				"com.example.vendor": "Acme",
   320  				"com.example.license": "GPL",
   321  				"com.example.version": "1.0"
   322  			},
   323  			"MacAddress": "",
   324  			"NetworkDisabled": false,
   325  			"OnBuild": null,
   326  			"OpenStdin": false,
   327  			"PortSpecs": null,
   328  			"StdinOnce": false,
   329  			"Tty": false,
   330  			"User": "",
   331  			"Volumes": null,
   332  			"WorkingDir": ""
   333  		},
   334  		"Created": "2015-01-06T15:47:31.485331387Z",
   335  		"Driver": "devicemapper",
   336  		"ExecDriver": "native-0.2",
   337  		"ExecIDs": null,
   338  		"HostConfig": {
   339  			"Binds": null,
   340  			"CapAdd": null,
   341  			"CapDrop": null,
   342  			"ContainerIDFile": "",
   343  			"CpusetCpus": "",
   344  			"CpuShares": 0,
   345  			"Devices": [],
   346  			"Dns": null,
   347  			"DnsSearch": null,
   348  			"ExtraHosts": null,
   349  			"IpcMode": "",
   350  			"Links": null,
   351  			"LxcConf": [],
   352  			"Memory": 0,
   353  			"MemorySwap": 0,
   354  			"NetworkMode": "bridge",
   355  			"PortBindings": {},
   356  			"Privileged": false,
   357  			"ReadonlyRootfs": false,
   358  			"PublishAllPorts": false,
   359  			"RestartPolicy": {
   360  				"MaximumRetryCount": 2,
   361  				"Name": "on-failure"
   362  			},
   363  			"LogConfig": {
   364  				"Config": null,
   365  				"Type": "json-file"
   366  			},
   367  			"SecurityOpt": null,
   368  			"VolumesFrom": null,
   369  			"Ulimits": [{}]
   370  		},
   371  		"HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname",
   372  		"HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts",
   373  		"LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
   374  		"Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39",
   375  		"Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2",
   376  		"MountLabel": "",
   377  		"Name": "/boring_euclid",
   378  		"NetworkSettings": {
   379  			"Bridge": "",
   380  			"Gateway": "",
   381  			"IPAddress": "",
   382  			"IPPrefixLen": 0,
   383  			"MacAddress": "",
   384  			"PortMapping": null,
   385  			"Ports": null
   386  		},
   387  		"Path": "/bin/sh",
   388  		"ProcessLabel": "",
   389  		"ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf",
   390  		"RestartCount": 1,
   391  		"State": {
   392  			"Error": "",
   393  			"ExitCode": 9,
   394  			"FinishedAt": "2015-01-06T15:47:32.080254511Z",
   395  			"OOMKilled": false,
   396  			"Paused": false,
   397  			"Pid": 0,
   398  			"Restarting": false,
   399  			"Running": false,
   400  			"StartedAt": "2015-01-06T15:47:32.072697474Z"
   401  		},
   402  		"Volumes": {},
   403  		"VolumesRW": {}
   404  	}
   405  
   406  Status Codes:
   407  
   408  -   **200** – no error
   409  -   **404** – no such container
   410  -   **500** – server error
   411  
   412  ### List processes running inside a container
   413  
   414  `GET /containers/(id)/top`
   415  
   416  List processes running inside the container `id`
   417  
   418  **Example request**:
   419  
   420          GET /containers/4fa6e0f0c678/top HTTP/1.1
   421  
   422  **Example response**:
   423  
   424          HTTP/1.1 200 OK
   425          Content-Type: application/json
   426  
   427          {
   428               "Titles": [
   429                       "USER",
   430                       "PID",
   431                       "%CPU",
   432                       "%MEM",
   433                       "VSZ",
   434                       "RSS",
   435                       "TTY",
   436                       "STAT",
   437                       "START",
   438                       "TIME",
   439                       "COMMAND"
   440                       ],
   441               "Processes": [
   442                       ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
   443                       ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
   444               ]
   445          }
   446  
   447  Query Parameters:
   448  
   449  -   **ps_args** – ps arguments to use (e.g., aux)
   450  
   451  Status Codes:
   452  
   453  -   **200** – no error
   454  -   **404** – no such container
   455  -   **500** – server error
   456  
   457  ### Get container logs
   458  
   459  `GET /containers/(id)/logs`
   460  
   461  Get stdout and stderr logs from the container ``id``
   462  
   463  > **Note**:
   464  > This endpoint works only for containers with `json-file` logging driver.
   465  
   466  **Example request**:
   467  
   468         GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1&timestamps=1&follow=1&tail=10 HTTP/1.1
   469  
   470  **Example response**:
   471  
   472         HTTP/1.1 101 UPGRADED
   473         Content-Type: application/vnd.docker.raw-stream
   474         Connection: Upgrade
   475         Upgrade: tcp
   476  
   477         {{ STREAM }}
   478  
   479  Query Parameters:
   480  
   481  -   **follow** – 1/True/true or 0/False/false, return stream. Default false
   482  -   **stdout** – 1/True/true or 0/False/false, show stdout log. Default false
   483  -   **stderr** – 1/True/true or 0/False/false, show stderr log. Default false
   484  -   **timestamps** – 1/True/true or 0/False/false, print timestamps for
   485          every log line. Default false
   486  -   **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all
   487  
   488  Status Codes:
   489  
   490  -   **101** – no error, hints proxy about hijacking
   491  -   **200** – no error, no upgrade header found
   492  -   **404** – no such container
   493  -   **500** – server error
   494  
   495  ### Inspect changes on a container's filesystem
   496  
   497  `GET /containers/(id)/changes`
   498  
   499  Inspect changes on container `id`'s filesystem
   500  
   501  **Example request**:
   502  
   503          GET /containers/4fa6e0f0c678/changes HTTP/1.1
   504  
   505  **Example response**:
   506  
   507          HTTP/1.1 200 OK
   508          Content-Type: application/json
   509  
   510          [
   511               {
   512                       "Path": "/dev",
   513                       "Kind": 0
   514               },
   515               {
   516                       "Path": "/dev/kmsg",
   517                       "Kind": 1
   518               },
   519               {
   520                       "Path": "/test",
   521                       "Kind": 1
   522               }
   523          ]
   524  
   525  Values for `Kind`:
   526  
   527  - `0`: Modify
   528  - `1`: Add
   529  - `2`: Delete
   530  
   531  Status Codes:
   532  
   533  -   **200** – no error
   534  -   **404** – no such container
   535  -   **500** – server error
   536  
   537  ### Export a container
   538  
   539  `GET /containers/(id)/export`
   540  
   541  Export the contents of container `id`
   542  
   543  **Example request**:
   544  
   545          GET /containers/4fa6e0f0c678/export HTTP/1.1
   546  
   547  **Example response**:
   548  
   549          HTTP/1.1 200 OK
   550          Content-Type: application/octet-stream
   551  
   552          {{ TAR STREAM }}
   553  
   554  Status Codes:
   555  
   556  -   **200** – no error
   557  -   **404** – no such container
   558  -   **500** – server error
   559  
   560  ### Get container stats based on resource usage
   561  
   562  `GET /containers/(id)/stats`
   563  
   564  This endpoint returns a live stream of a container's resource usage statistics.
   565  
   566  > **Note**: this functionality currently only works when using the *libcontainer* exec-driver.
   567  
   568  **Example request**:
   569  
   570          GET /containers/redis1/stats HTTP/1.1
   571  
   572  **Example response**:
   573  
   574          HTTP/1.1 200 OK
   575          Content-Type: application/json
   576  
   577          {
   578             "read" : "2015-01-08T22:57:31.547920715Z",
   579             "network" : {
   580                "rx_dropped" : 0,
   581                "rx_bytes" : 648,
   582                "rx_errors" : 0,
   583                "tx_packets" : 8,
   584                "tx_dropped" : 0,
   585                "rx_packets" : 8,
   586                "tx_errors" : 0,
   587                "tx_bytes" : 648
   588             },
   589             "memory_stats" : {
   590                "stats" : {
   591                   "total_pgmajfault" : 0,
   592                   "cache" : 0,
   593                   "mapped_file" : 0,
   594                   "total_inactive_file" : 0,
   595                   "pgpgout" : 414,
   596                   "rss" : 6537216,
   597                   "total_mapped_file" : 0,
   598                   "writeback" : 0,
   599                   "unevictable" : 0,
   600                   "pgpgin" : 477,
   601                   "total_unevictable" : 0,
   602                   "pgmajfault" : 0,
   603                   "total_rss" : 6537216,
   604                   "total_rss_huge" : 6291456,
   605                   "total_writeback" : 0,
   606                   "total_inactive_anon" : 0,
   607                   "rss_huge" : 6291456,
   608                   "hierarchical_memory_limit" : 67108864,
   609                   "total_pgfault" : 964,
   610                   "total_active_file" : 0,
   611                   "active_anon" : 6537216,
   612                   "total_active_anon" : 6537216,
   613                   "total_pgpgout" : 414,
   614                   "total_cache" : 0,
   615                   "inactive_anon" : 0,
   616                   "active_file" : 0,
   617                   "pgfault" : 964,
   618                   "inactive_file" : 0,
   619                   "total_pgpgin" : 477
   620                },
   621                "max_usage" : 6651904,
   622                "usage" : 6537216,
   623                "failcnt" : 0,
   624                "limit" : 67108864
   625             },
   626             "blkio_stats" : {},
   627             "cpu_stats" : {
   628                "cpu_usage" : {
   629                   "percpu_usage" : [
   630                      16970827,
   631                      1839451,
   632                      7107380,
   633                      10571290
   634                   ],
   635                   "usage_in_usermode" : 10000000,
   636                   "total_usage" : 36488948,
   637                   "usage_in_kernelmode" : 20000000
   638                },
   639                "system_cpu_usage" : 20091722000000000,
   640                "throttling_data" : {}
   641             }
   642          }
   643  
   644  Status Codes:
   645  
   646  -   **200** – no error
   647  -   **404** – no such container
   648  -   **500** – server error
   649  
   650  ### Resize a container TTY
   651  
   652  `POST /containers/(id)/resize?h=<height>&w=<width>`
   653  
   654  Resize the TTY for container with  `id`. The container must be restarted for the resize to take effect.
   655  
   656  **Example request**:
   657  
   658          POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
   659  
   660  **Example response**:
   661  
   662          HTTP/1.1 200 OK
   663          Content-Length: 0
   664          Content-Type: text/plain; charset=utf-8
   665  
   666  Status Codes:
   667  
   668  -   **200** – no error
   669  -   **404** – No such container
   670  -   **500** – Cannot resize container
   671  
   672  ### Start a container
   673  
   674  `POST /containers/(id)/start`
   675  
   676  Start the container `id`
   677  
   678  **Example request**:
   679  
   680          POST /containers/(id)/start HTTP/1.1
   681          Content-Type: application/json
   682  
   683          {
   684              "Binds": ["/tmp:/tmp"],
   685              "Links": ["redis3:redis"],
   686              "LxcConf": {"lxc.utsname":"docker"},
   687              "Memory": 0,
   688              "MemorySwap": 0,
   689              "CpuShares": 512,
   690              "CpusetCpus": "0,1",
   691              "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
   692              "PublishAllPorts": false,
   693              "Privileged": false,
   694              "ReadonlyRootfs": false,
   695              "Dns": ["8.8.8.8"],
   696              "DnsSearch": [""],
   697              "ExtraHosts": null,
   698              "VolumesFrom": ["parent", "other:ro"],
   699              "CapAdd": ["NET_ADMIN"],
   700              "CapDrop": ["MKNOD"],
   701              "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
   702              "NetworkMode": "bridge",
   703              "Devices": [],
   704              "Ulimits": [{}],
   705              "LogConfig": { "Type": "json-file", Config: {} },
   706              "SecurityOpt": [""],
   707              "CgroupParent": ""
   708          }
   709  
   710  **Example response**:
   711  
   712          HTTP/1.1 204 No Content
   713  
   714  Json Parameters:
   715  
   716  -   **Binds** – A list of volume bindings for this container. Each volume
   717          binding is a string of the form `container_path` (to create a new
   718          volume for the container), `host_path:container_path` (to bind-mount
   719          a host path into the container), or `host_path:container_path:ro`
   720          (to make the bind-mount read-only inside the container).
   721  -   **Links** - A list of links for the container. Each link entry should be of
   722        of the form `container_name:alias`.
   723  -   **LxcConf** - LXC specific configurations. These configurations will only
   724        work when using the `lxc` execution driver.
   725  -   **PortBindings** - A map of exposed container ports and the host port they
   726        should map to. It should be specified in the form
   727        `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
   728        Take note that `port` is specified as a string and not an integer value.
   729  -   **PublishAllPorts** - Allocates a random host port for all of a container's
   730        exposed ports. Specified as a boolean value.
   731  -   **Privileged** - Gives the container full access to the host. Specified as
   732        a boolean value.
   733  -   **ReadonlyRootfs** - Mount the container's root filesystem as read only.
   734        Specified as a boolean value.
   735  -   **Dns** - A list of dns servers for the container to use.
   736  -   **DnsSearch** - A list of DNS search domains
   737  -   **ExtraHosts** - A list of hostnames/IP mappings to be added to the
   738      container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
   739  -   **VolumesFrom** - A list of volumes to inherit from another container.
   740        Specified in the form `<container name>[:<ro|rw>]`
   741  -   **CapAdd** - A list of kernel capabilities to add to the container.
   742  -   **Capdrop** - A list of kernel capabilities to drop from the container.
   743  -   **RestartPolicy** – The behavior to apply when the container exits.  The
   744          value is an object with a `Name` property of either `"always"` to
   745          always restart or `"on-failure"` to restart only when the container
   746          exit code is non-zero.  If `on-failure` is used, `MaximumRetryCount`
   747          controls the number of times to retry before giving up.
   748          The default is not to restart. (optional)
   749          An ever increasing delay (double the previous delay, starting at 100mS)
   750          is added before each restart to prevent flooding the server.
   751  -   **NetworkMode** - Sets the networking mode for the container. Supported
   752        values are: `bridge`, `host`, and `container:<name|id>`
   753  -   **Devices** - A list of devices to add to the container specified in the
   754        form
   755        `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
   756  -   **Ulimits** - A list of ulimits to be set in the container, specified as
   757        `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
   758        `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard", 2048 }}`
   759  -   **SecurityOpt**: A list of string values to customize labels for MLS
   760      systems, such as SELinux.
   761  -   **LogConfig** - Log configuration for the container, specified as
   762        `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
   763        Available types: `json-file`, `syslog`, `none`.
   764        `json-file` logging driver.
   765  -   **CgroupParent** - Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
   766  
   767  Status Codes:
   768  
   769  -   **204** – no error
   770  -   **304** – container already started
   771  -   **404** – no such container
   772  -   **500** – server error
   773  
   774  ### Stop a container
   775  
   776  `POST /containers/(id)/stop`
   777  
   778  Stop the container `id`
   779  
   780  **Example request**:
   781  
   782          POST /containers/e90e34656806/stop?t=5 HTTP/1.1
   783  
   784  **Example response**:
   785  
   786          HTTP/1.1 204 No Content
   787  
   788  Query Parameters:
   789  
   790  -   **t** – number of seconds to wait before killing the container
   791  
   792  Status Codes:
   793  
   794  -   **204** – no error
   795  -   **304** – container already stopped
   796  -   **404** – no such container
   797  -   **500** – server error
   798  
   799  ### Restart a container
   800  
   801  `POST /containers/(id)/restart`
   802  
   803  Restart the container `id`
   804  
   805  **Example request**:
   806  
   807          POST /containers/e90e34656806/restart?t=5 HTTP/1.1
   808  
   809  **Example response**:
   810  
   811          HTTP/1.1 204 No Content
   812  
   813  Query Parameters:
   814  
   815  -   **t** – number of seconds to wait before killing the container
   816  
   817  Status Codes:
   818  
   819  -   **204** – no error
   820  -   **404** – no such container
   821  -   **500** – server error
   822  
   823  ### Kill a container
   824  
   825  `POST /containers/(id)/kill`
   826  
   827  Kill the container `id`
   828  
   829  **Example request**:
   830  
   831          POST /containers/e90e34656806/kill HTTP/1.1
   832  
   833  **Example response**:
   834  
   835          HTTP/1.1 204 No Content
   836  
   837  Query Parameters
   838  
   839  -   **signal** - Signal to send to the container: integer or string like "SIGINT".
   840          When not set, SIGKILL is assumed and the call will waits for the container to exit.
   841  
   842  Status Codes:
   843  
   844  -   **204** – no error
   845  -   **404** – no such container
   846  -   **500** – server error
   847  
   848  ### Rename a container
   849  
   850  `POST /containers/(id)/rename`
   851  
   852  Rename the container `id` to a `new_name`
   853  
   854  **Example request**:
   855  
   856          POST /containers/e90e34656806/rename?name=new_name HTTP/1.1
   857  
   858  **Example response**:
   859  
   860          HTTP/1.1 204 No Content
   861  
   862  Query Parameters:
   863  
   864  -   **name** – new name for the container
   865  
   866  Status Codes:
   867  
   868  -   **204** – no error
   869  -   **404** – no such container
   870  -   **409** - conflict name already assigned
   871  -   **500** – server error
   872  
   873  ### Pause a container
   874  
   875  `POST /containers/(id)/pause`
   876  
   877  Pause the container `id`
   878  
   879  **Example request**:
   880  
   881          POST /containers/e90e34656806/pause HTTP/1.1
   882  
   883  **Example response**:
   884  
   885          HTTP/1.1 204 No Content
   886  
   887  Status Codes:
   888  
   889  -   **204** – no error
   890  -   **404** – no such container
   891  -   **500** – server error
   892  
   893  ### Unpause a container
   894  
   895  `POST /containers/(id)/unpause`
   896  
   897  Unpause the container `id`
   898  
   899  **Example request**:
   900  
   901          POST /containers/e90e34656806/unpause HTTP/1.1
   902  
   903  **Example response**:
   904  
   905          HTTP/1.1 204 No Content
   906  
   907  Status Codes:
   908  
   909  -   **204** – no error
   910  -   **404** – no such container
   911  -   **500** – server error
   912  
   913  ### Attach to a container
   914  
   915  `POST /containers/(id)/attach`
   916  
   917  Attach to the container `id`
   918  
   919  **Example request**:
   920  
   921          POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
   922  
   923  **Example response**:
   924  
   925          HTTP/1.1 101 UPGRADED
   926          Content-Type: application/vnd.docker.raw-stream
   927          Connection: Upgrade
   928          Upgrade: tcp
   929  
   930          {{ STREAM }}
   931  
   932  Query Parameters:
   933  
   934  -   **logs** – 1/True/true or 0/False/false, return logs. Default false
   935  -   **stream** – 1/True/true or 0/False/false, return stream.
   936          Default false
   937  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   938          to stdin. Default false
   939  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   940          stdout log, if stream=true, attach to stdout. Default false
   941  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   942          stderr log, if stream=true, attach to stderr. Default false
   943  
   944  Status Codes:
   945  
   946  -   **101** – no error, hints proxy about hijacking
   947  -   **200** – no error, no upgrade header found
   948  -   **400** – bad parameter
   949  -   **404** – no such container
   950  -   **500** – server error
   951  
   952      **Stream details**:
   953  
   954      When using the TTY setting is enabled in
   955      [`POST /containers/create`
   956      ](/reference/api/docker_remote_api_v1.9/#create-a-container "POST /containers/create"),
   957      the stream is the raw data from the process PTY and client's stdin.
   958      When the TTY is disabled, then the stream is multiplexed to separate
   959      stdout and stderr.
   960  
   961      The format is a **Header** and a **Payload** (frame).
   962  
   963      **HEADER**
   964  
   965      The header will contain the information on which stream write the
   966      stream (stdout or stderr). It also contain the size of the
   967      associated frame encoded on the last 4 bytes (uint32).
   968  
   969      It is encoded on the first 8 bytes like this:
   970  
   971          header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
   972  
   973      `STREAM_TYPE` can be:
   974  
   975  -   0: stdin (will be written on stdout)
   976  -   1: stdout
   977  -   2: stderr
   978  
   979      `SIZE1, SIZE2, SIZE3, SIZE4` are the 4 bytes of
   980      the uint32 size encoded as big endian.
   981  
   982      **PAYLOAD**
   983  
   984      The payload is the raw stream.
   985  
   986      **IMPLEMENTATION**
   987  
   988      The simplest way to implement the Attach protocol is the following:
   989  
   990      1.  Read 8 bytes
   991      2.  chose stdout or stderr depending on the first byte
   992      3.  Extract the frame size from the last 4 bytes
   993      4.  Read the extracted size and output it on the correct output
   994      5.  Goto 1
   995  
   996  ### Attach to a container (websocket)
   997  
   998  `GET /containers/(id)/attach/ws`
   999  
  1000  Attach to the container `id` via websocket
  1001  
  1002  Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
  1003  
  1004  **Example request**
  1005  
  1006          GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
  1007  
  1008  **Example response**
  1009  
  1010          {{ STREAM }}
  1011  
  1012  Query Parameters:
  1013  
  1014  -   **logs** – 1/True/true or 0/False/false, return logs. Default false
  1015  -   **stream** – 1/True/true or 0/False/false, return stream.
  1016          Default false
  1017  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
  1018          to stdin. Default false
  1019  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
  1020          stdout log, if stream=true, attach to stdout. Default false
  1021  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
  1022          stderr log, if stream=true, attach to stderr. Default false
  1023  
  1024  Status Codes:
  1025  
  1026  -   **200** – no error
  1027  -   **400** – bad parameter
  1028  -   **404** – no such container
  1029  -   **500** – server error
  1030  
  1031  ### Wait a container
  1032  
  1033  `POST /containers/(id)/wait`
  1034  
  1035  Block until container `id` stops, then returns the exit code
  1036  
  1037  **Example request**:
  1038  
  1039          POST /containers/16253994b7c4/wait HTTP/1.1
  1040  
  1041  **Example response**:
  1042  
  1043          HTTP/1.1 200 OK
  1044          Content-Type: application/json
  1045  
  1046          {"StatusCode": 0}
  1047  
  1048  Status Codes:
  1049  
  1050  -   **200** – no error
  1051  -   **404** – no such container
  1052  -   **500** – server error
  1053  
  1054  ### Remove a container
  1055  
  1056  `DELETE /containers/(id)`
  1057  
  1058  Remove the container `id` from the filesystem
  1059  
  1060  **Example request**:
  1061  
  1062          DELETE /containers/16253994b7c4?v=1 HTTP/1.1
  1063  
  1064  **Example response**:
  1065  
  1066          HTTP/1.1 204 No Content
  1067  
  1068  Query Parameters:
  1069  
  1070  -   **v** – 1/True/true or 0/False/false, Remove the volumes
  1071          associated to the container. Default false
  1072  -   **force** - 1/True/true or 0/False/false, Kill then remove the container.
  1073          Default false
  1074  
  1075  Status Codes:
  1076  
  1077  -   **204** – no error
  1078  -   **400** – bad parameter
  1079  -   **404** – no such container
  1080  -   **500** – server error
  1081  
  1082  ### Copy files or folders from a container
  1083  
  1084  `POST /containers/(id)/copy`
  1085  
  1086  Copy files or folders of container `id`
  1087  
  1088  **Example request**:
  1089  
  1090          POST /containers/4fa6e0f0c678/copy HTTP/1.1
  1091          Content-Type: application/json
  1092  
  1093          {
  1094               "Resource": "test.txt"
  1095          }
  1096  
  1097  **Example response**:
  1098  
  1099          HTTP/1.1 200 OK
  1100          Content-Type: application/x-tar
  1101  
  1102          {{ TAR STREAM }}
  1103  
  1104  Status Codes:
  1105  
  1106  -   **200** – no error
  1107  -   **404** – no such container
  1108  -   **500** – server error
  1109  
  1110  ## 2.2 Images
  1111  
  1112  ### List Images
  1113  
  1114  `GET /images/json`
  1115  
  1116  **Example request**:
  1117  
  1118          GET /images/json?all=0 HTTP/1.1
  1119  
  1120  **Example response**:
  1121  
  1122          HTTP/1.1 200 OK
  1123          Content-Type: application/json
  1124  
  1125          [
  1126            {
  1127               "RepoTags": [
  1128                 "ubuntu:12.04",
  1129                 "ubuntu:precise",
  1130                 "ubuntu:latest"
  1131               ],
  1132               "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
  1133               "Created": 1365714795,
  1134               "Size": 131506275,
  1135               "VirtualSize": 131506275
  1136            },
  1137            {
  1138               "RepoTags": [
  1139                 "ubuntu:12.10",
  1140                 "ubuntu:quantal"
  1141               ],
  1142               "ParentId": "27cf784147099545",
  1143               "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1144               "Created": 1364102658,
  1145               "Size": 24653,
  1146               "VirtualSize": 180116135
  1147            }
  1148          ]
  1149  
  1150  **Example request, with digest information**:
  1151  
  1152          GET /images/json?digests=1 HTTP/1.1
  1153  
  1154  **Example response, with digest information**:
  1155  
  1156          HTTP/1.1 200 OK
  1157          Content-Type: application/json
  1158  
  1159          [
  1160            {
  1161              "Created": 1420064636,
  1162              "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125",
  1163              "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2",
  1164              "RepoDigests": [
  1165                "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
  1166              ],
  1167              "RepoTags": [
  1168                "localhost:5000/test/busybox:latest",
  1169                "playdate:latest"
  1170              ],
  1171              "Size": 0,
  1172              "VirtualSize": 2429728
  1173            }
  1174          ]
  1175  
  1176  The response shows a single image `Id` associated with two repositories
  1177  (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use
  1178  either of the `RepoTags` values `localhost:5000/test/busybox:latest` or
  1179  `playdate:latest` to reference the image.
  1180  
  1181  You can also use `RepoDigests` values to reference an image. In this response,
  1182  the array has only one reference and that is to the
  1183  `localhost:5000/test/busybox` repository; the `playdate` repository has no
  1184  digest. You can reference this digest using the value:
  1185  `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...`
  1186  
  1187  See the `docker run` and `docker build` commands for examples of digest and tag
  1188  references on the command line.
  1189  
  1190  Query Parameters:
  1191  
  1192  -   **all** – 1/True/true or 0/False/false, default false
  1193  -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
  1194    -   dangling=true
  1195    -   label=`key` or `key=value` of an image label
  1196  
  1197  ### Build image from a Dockerfile
  1198  
  1199  `POST /build`
  1200  
  1201  Build an image from a Dockerfile
  1202  
  1203  **Example request**:
  1204  
  1205          POST /build HTTP/1.1
  1206  
  1207          {{ TAR STREAM }}
  1208  
  1209  **Example response**:
  1210  
  1211          HTTP/1.1 200 OK
  1212          Content-Type: application/json
  1213  
  1214          {"stream": "Step 1..."}
  1215          {"stream": "..."}
  1216          {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
  1217  
  1218  The input stream must be a tar archive compressed with one of the
  1219  following algorithms: identity (no compression), gzip, bzip2, xz.
  1220  
  1221  The archive must include a build instructions file, typically called
  1222  `Dockerfile` at the root of the archive. The `dockerfile` parameter may be
  1223  used to specify a different build instructions file by having its value be
  1224  the path to the alternate build instructions file to use.
  1225  
  1226  The archive may include any number of other files,
  1227  which will be accessible in the build context (See the [*ADD build
  1228  command*](/reference/builder/#dockerbuilder)).
  1229  
  1230  The build will also be canceled if the client drops the connection by quitting
  1231  or being killed.
  1232  
  1233  Query Parameters:
  1234  
  1235  -   **dockerfile** - path within the build context to the Dockerfile. This is 
  1236          ignored if `remote` is specified and points to an individual filename.
  1237  -   **t** – repository name (and optionally a tag) to be applied to
  1238          the resulting image in case of success
  1239  -   **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the 
  1240          URI specifies a filename, the file's contents are placed into a file 
  1241  		called `Dockerfile`.
  1242  -   **q** – suppress verbose build output
  1243  -   **nocache** – do not use the cache when building the image
  1244  -   **pull** - attempt to pull the image even if an older image exists locally
  1245  -   **rm** - remove intermediate containers after a successful build (default behavior)
  1246  -   **forcerm** - always remove intermediate containers (includes rm)
  1247  -   **memory** - set memory limit for build
  1248  -   **memswap** - Total memory (memory + swap), `-1` to disable swap
  1249  -   **cpushares** - CPU shares (relative weight)
  1250  -   **cpusetcpus** - CPUs in which to allow execution, e.g., `0-3`, `0,1`
  1251  
  1252      Request Headers:
  1253  
  1254  -   **Content-type** – should be set to `"application/tar"`.
  1255  -   **X-Registry-Config** – base64-encoded ConfigFile object
  1256  
  1257  Status Codes:
  1258  
  1259  -   **200** – no error
  1260  -   **500** – server error
  1261  
  1262  ### Create an image
  1263  
  1264  `POST /images/create`
  1265  
  1266  Create an image, either by pulling it from the registry or by importing it
  1267  
  1268  **Example request**:
  1269  
  1270          POST /images/create?fromImage=ubuntu HTTP/1.1
  1271  
  1272  **Example response**:
  1273  
  1274          HTTP/1.1 200 OK
  1275          Content-Type: application/json
  1276  
  1277          {"status": "Pulling..."}
  1278          {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
  1279          {"error": "Invalid..."}
  1280          ...
  1281  
  1282      When using this endpoint to pull an image from the registry, the
  1283      `X-Registry-Auth` header can be used to include
  1284      a base64-encoded AuthConfig object.
  1285  
  1286  Query Parameters:
  1287  
  1288  -   **fromImage** – name of the image to pull
  1289  -   **fromSrc** – source to import.  The value may be a URL from which the image
  1290          can be retrieved or `-` to read the image from the request body.
  1291  -   **repo** – repository
  1292  -   **tag** – tag
  1293  -   **registry** – the registry to pull from
  1294  
  1295      Request Headers:
  1296  
  1297  -   **X-Registry-Auth** – base64-encoded AuthConfig object
  1298  
  1299  Status Codes:
  1300  
  1301  -   **200** – no error
  1302  -   **500** – server error
  1303  
  1304  
  1305  
  1306  ### Inspect an image
  1307  
  1308  `GET /images/(name)/json`
  1309  
  1310  Return low-level information on the image `name`
  1311  
  1312  **Example request**:
  1313  
  1314          GET /images/ubuntu/json HTTP/1.1
  1315  
  1316  **Example response**:
  1317  
  1318          HTTP/1.1 200 OK
  1319          Content-Type: application/json
  1320  
  1321          {
  1322               "Created": "2013-03-23T22:24:18.818426-07:00",
  1323               "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  1324               "ContainerConfig":
  1325                       {
  1326                               "Hostname": "",
  1327                               "User": "",
  1328                               "AttachStdin": false,
  1329                               "AttachStdout": false,
  1330                               "AttachStderr": false,
  1331                               "PortSpecs": null,
  1332                               "Tty": true,
  1333                               "OpenStdin": true,
  1334                               "StdinOnce": false,
  1335                               "Env": null,
  1336                               "Cmd": ["/bin/bash"],
  1337                               "Dns": null,
  1338                               "Image": "ubuntu",
  1339                               "Labels": {
  1340                                   "com.example.vendor": "Acme",
  1341                                   "com.example.license": "GPL",
  1342                                   "com.example.version": "1.0"
  1343                               },
  1344                               "Volumes": null,
  1345                               "VolumesFrom": "",
  1346                               "WorkingDir": ""
  1347                       },
  1348               "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1349               "Parent": "27cf784147099545",
  1350               "Size": 6824592
  1351          }
  1352  
  1353  Status Codes:
  1354  
  1355  -   **200** – no error
  1356  -   **404** – no such image
  1357  -   **500** – server error
  1358  
  1359  ### Get the history of an image
  1360  
  1361  `GET /images/(name)/history`
  1362  
  1363  Return the history of the image `name`
  1364  
  1365  **Example request**:
  1366  
  1367          GET /images/ubuntu/history HTTP/1.1
  1368  
  1369  **Example response**:
  1370  
  1371          HTTP/1.1 200 OK
  1372          Content-Type: application/json
  1373  
  1374          [
  1375               {
  1376                       "Id": "b750fe79269d",
  1377                       "Created": 1364102658,
  1378                       "CreatedBy": "/bin/bash"
  1379               },
  1380               {
  1381                       "Id": "27cf78414709",
  1382                       "Created": 1364068391,
  1383                       "CreatedBy": ""
  1384               }
  1385          ]
  1386  
  1387  Status Codes:
  1388  
  1389  -   **200** – no error
  1390  -   **404** – no such image
  1391  -   **500** – server error
  1392  
  1393  ### Push an image on the registry
  1394  
  1395  `POST /images/(name)/push`
  1396  
  1397  Push the image `name` on the registry
  1398  
  1399  **Example request**:
  1400  
  1401          POST /images/test/push HTTP/1.1
  1402  
  1403  **Example response**:
  1404  
  1405          HTTP/1.1 200 OK
  1406          Content-Type: application/json
  1407  
  1408          {"status": "Pushing..."}
  1409          {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
  1410          {"error": "Invalid..."}
  1411          ...
  1412  
  1413      If you wish to push an image on to a private registry, that image must already have been tagged
  1414      into a repository which references that registry host name and port.  This repository name should
  1415      then be used in the URL. This mirrors the flow of the CLI.
  1416  
  1417  **Example request**:
  1418  
  1419          POST /images/registry.acme.com:5000/test/push HTTP/1.1
  1420  
  1421  
  1422  Query Parameters:
  1423  
  1424  -   **tag** – the tag to associate with the image on the registry, optional
  1425  
  1426  Request Headers:
  1427  
  1428  -   **X-Registry-Auth** – include a base64-encoded AuthConfig
  1429          object.
  1430  
  1431  Status Codes:
  1432  
  1433  -   **200** – no error
  1434  -   **404** – no such image
  1435  -   **500** – server error
  1436  
  1437  ### Tag an image into a repository
  1438  
  1439  `POST /images/(name)/tag`
  1440  
  1441  Tag the image `name` into a repository
  1442  
  1443  **Example request**:
  1444  
  1445          POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
  1446  
  1447  **Example response**:
  1448  
  1449          HTTP/1.1 201 OK
  1450  
  1451  Query Parameters:
  1452  
  1453  -   **repo** – The repository to tag in
  1454  -   **force** – 1/True/true or 0/False/false, default false
  1455  -   **tag** - The new tag name
  1456  
  1457  Status Codes:
  1458  
  1459  -   **201** – no error
  1460  -   **400** – bad parameter
  1461  -   **404** – no such image
  1462  -   **409** – conflict
  1463  -   **500** – server error
  1464  
  1465  ### Remove an image
  1466  
  1467  `DELETE /images/(name)`
  1468  
  1469  Remove the image `name` from the filesystem
  1470  
  1471  **Example request**:
  1472  
  1473          DELETE /images/test HTTP/1.1
  1474  
  1475  **Example response**:
  1476  
  1477          HTTP/1.1 200 OK
  1478          Content-type: application/json
  1479  
  1480          [
  1481           {"Untagged": "3e2f21a89f"},
  1482           {"Deleted": "3e2f21a89f"},
  1483           {"Deleted": "53b4f83ac9"}
  1484          ]
  1485  
  1486  Query Parameters:
  1487  
  1488  -   **force** – 1/True/true or 0/False/false, default false
  1489  -   **noprune** – 1/True/true or 0/False/false, default false
  1490  
  1491  Status Codes:
  1492  
  1493  -   **200** – no error
  1494  -   **404** – no such image
  1495  -   **409** – conflict
  1496  -   **500** – server error
  1497  
  1498  ### Search images
  1499  
  1500  `GET /images/search`
  1501  
  1502  Search for an image on [Docker Hub](https://hub.docker.com).
  1503  
  1504  > **Note**:
  1505  > The response keys have changed from API v1.6 to reflect the JSON
  1506  > sent by the registry server to the docker daemon's request.
  1507  
  1508  **Example request**:
  1509  
  1510          GET /images/search?term=sshd HTTP/1.1
  1511  
  1512  **Example response**:
  1513  
  1514          HTTP/1.1 200 OK
  1515          Content-Type: application/json
  1516  
  1517          [
  1518                  {
  1519                      "description": "",
  1520                      "is_official": false,
  1521                      "is_automated": false,
  1522                      "name": "wma55/u1210sshd",
  1523                      "star_count": 0
  1524                  },
  1525                  {
  1526                      "description": "",
  1527                      "is_official": false,
  1528                      "is_automated": false,
  1529                      "name": "jdswinbank/sshd",
  1530                      "star_count": 0
  1531                  },
  1532                  {
  1533                      "description": "",
  1534                      "is_official": false,
  1535                      "is_automated": false,
  1536                      "name": "vgauthier/sshd",
  1537                      "star_count": 0
  1538                  }
  1539          ...
  1540          ]
  1541  
  1542  Query Parameters:
  1543  
  1544  -   **term** – term to search
  1545  
  1546  Status Codes:
  1547  
  1548  -   **200** – no error
  1549  -   **500** – server error
  1550  
  1551  ## 2.3 Misc
  1552  
  1553  ### Check auth configuration
  1554  
  1555  `POST /auth`
  1556  
  1557  Get the default username and email
  1558  
  1559  **Example request**:
  1560  
  1561          POST /auth HTTP/1.1
  1562          Content-Type: application/json
  1563  
  1564          {
  1565               "username":" hannibal",
  1566               "password: "xxxx",
  1567               "email": "hannibal@a-team.com",
  1568               "serveraddress": "https://index.docker.io/v1/"
  1569          }
  1570  
  1571  **Example response**:
  1572  
  1573          HTTP/1.1 200 OK
  1574  
  1575  Status Codes:
  1576  
  1577  -   **200** – no error
  1578  -   **204** – no error
  1579  -   **500** – server error
  1580  
  1581  ### Display system-wide information
  1582  
  1583  `GET /info`
  1584  
  1585  Display system-wide information
  1586  
  1587  **Example request**:
  1588  
  1589          GET /info HTTP/1.1
  1590  
  1591  **Example response**:
  1592  
  1593          HTTP/1.1 200 OK
  1594          Content-Type: application/json
  1595  
  1596          {
  1597              "Containers": 11,
  1598              "Debug": 0,
  1599              "DockerRootDir": "/var/lib/docker",
  1600              "Driver": "btrfs",
  1601              "DriverStatus": [[""]],
  1602              "ExecutionDriver": "native-0.1",
  1603              "HttpProxy": "http://test:test@localhost:8080",
  1604              "HttpsProxy": "https://test:test@localhost:8080",
  1605              "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  1606              "IPv4Forwarding": 1,
  1607              "Images": 16,
  1608              "IndexServerAddress": "https://index.docker.io/v1/",
  1609              "InitPath": "/usr/bin/docker",
  1610              "InitSha1": "",
  1611              "KernelVersion": "3.12.0-1-amd64",
  1612              "Labels": [
  1613                  "storage=ssd"
  1614              ],
  1615              "MemTotal": 2099236864,
  1616              "MemoryLimit": 1,
  1617              "NCPU": 1,
  1618              "NEventsListener": 0,
  1619              "NFd": 11,
  1620              "NGoroutines": 21,
  1621              "Name": "prod-server-42",
  1622              "NoProxy": "9.81.1.160",
  1623              "OperatingSystem": "Boot2Docker",
  1624              "RegistryConfig": {
  1625                  "IndexConfigs": {
  1626                      "docker.io": {
  1627                          "Mirrors": null,
  1628                          "Name": "docker.io",
  1629                          "Official": true,
  1630                          "Secure": true
  1631                      }
  1632                  },
  1633                  "InsecureRegistryCIDRs": [
  1634                      "127.0.0.0/8"
  1635                  ]
  1636              },
  1637              "SwapLimit": 0,
  1638              "SystemTime": "2015-03-10T11:11:23.730591467-07:00"
  1639          }
  1640          
  1641  Status Codes:
  1642  
  1643  -   **200** – no error
  1644  -   **500** – server error
  1645  
  1646  ### Show the docker version information
  1647  
  1648  `GET /version`
  1649  
  1650  Show the docker version information
  1651  
  1652  **Example request**:
  1653  
  1654          GET /version HTTP/1.1
  1655  
  1656  **Example response**:
  1657  
  1658          HTTP/1.1 200 OK
  1659          Content-Type: application/json
  1660  
  1661          {
  1662               "Version": "1.5.0",
  1663               "Os": "linux",
  1664               "KernelVersion": "3.18.5-tinycore64",
  1665               "GoVersion": "go1.4.1",
  1666               "GitCommit": "a8a31ef",
  1667               "Arch": "amd64",
  1668               "ApiVersion": "1.18"
  1669          }
  1670  
  1671  Status Codes:
  1672  
  1673  -   **200** – no error
  1674  -   **500** – server error
  1675  
  1676  ### Ping the docker server
  1677  
  1678  `GET /_ping`
  1679  
  1680  Ping the docker server
  1681  
  1682  **Example request**:
  1683  
  1684          GET /_ping HTTP/1.1
  1685  
  1686  **Example response**:
  1687  
  1688          HTTP/1.1 200 OK
  1689          Content-Type: text/plain
  1690  
  1691          OK
  1692  
  1693  Status Codes:
  1694  
  1695  -   **200** - no error
  1696  -   **500** - server error
  1697  
  1698  ### Create a new image from a container's changes
  1699  
  1700  `POST /commit`
  1701  
  1702  Create a new image from a container's changes
  1703  
  1704  **Example request**:
  1705  
  1706          POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1707          Content-Type: application/json
  1708  
  1709          {
  1710               "Hostname": "",
  1711               "Domainname": "",
  1712               "User": "",
  1713               "AttachStdin": false,
  1714               "AttachStdout": true,
  1715               "AttachStderr": true,
  1716               "PortSpecs": null,
  1717               "Tty": false,
  1718               "OpenStdin": false,
  1719               "StdinOnce": false,
  1720               "Env": null,
  1721               "Cmd": [
  1722                       "date"
  1723               ],
  1724               "Volumes": {
  1725                       "/tmp": {}
  1726               },
  1727               "WorkingDir": "",
  1728               "NetworkDisabled": false,
  1729               "ExposedPorts": {
  1730                       "22/tcp": {}
  1731               }
  1732          }
  1733  
  1734  **Example response**:
  1735  
  1736          HTTP/1.1 201 Created
  1737          Content-Type: application/vnd.docker.raw-stream
  1738  
  1739          {"Id": "596069db4bf5"}
  1740  
  1741  Json Parameters:
  1742  
  1743  -  **config** - the container's configuration
  1744  
  1745  Query Parameters:
  1746  
  1747  -   **container** – source container
  1748  -   **repo** – repository
  1749  -   **tag** – tag
  1750  -   **comment** – commit message
  1751  -   **author** – author (e.g., "John Hannibal Smith
  1752      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1753  
  1754  Status Codes:
  1755  
  1756  -   **201** – no error
  1757  -   **404** – no such container
  1758  -   **500** – server error
  1759  
  1760  ### Monitor Docker's events
  1761  
  1762  `GET /events`
  1763  
  1764  Get container events from docker, either in real time via streaming, or via
  1765  polling (using since).
  1766  
  1767  Docker containers will report the following events:
  1768  
  1769      create, destroy, die, exec_create, exec_start, export, kill, oom, pause, restart, start, stop, unpause
  1770  
  1771  and Docker images will report:
  1772  
  1773      untag, delete
  1774  
  1775  **Example request**:
  1776  
  1777          GET /events?since=1374067924
  1778  
  1779  **Example response**:
  1780  
  1781          HTTP/1.1 200 OK
  1782          Content-Type: application/json
  1783  
  1784          {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1785          {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1786          {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1787          {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1788  
  1789  Query Parameters:
  1790  
  1791  -   **since** – timestamp used for polling
  1792  -   **until** – timestamp used for polling
  1793  -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  1794    -   event=&lt;string&gt; -- event to filter
  1795    -   image=&lt;string&gt; -- image to filter
  1796    -   container=&lt;string&gt; -- container to filter
  1797  
  1798  Status Codes:
  1799  
  1800  -   **200** – no error
  1801  -   **500** – server error
  1802  
  1803  ### Get a tarball containing all images in a repository
  1804  
  1805  `GET /images/(name)/get`
  1806  
  1807  Get a tarball containing all images and metadata for the repository specified
  1808  by `name`.
  1809  
  1810  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  1811  (and its parents) are returned. If `name` is an image ID, similarly only that
  1812  image (and its parents) are returned, but with the exclusion of the
  1813  'repositories' file in the tarball, as there were no image names referenced.
  1814  
  1815  See the [image tarball format](#image-tarball-format) for more details.
  1816  
  1817  **Example request**
  1818  
  1819          GET /images/ubuntu/get
  1820  
  1821  **Example response**:
  1822  
  1823          HTTP/1.1 200 OK
  1824          Content-Type: application/x-tar
  1825  
  1826          Binary data stream
  1827  
  1828  Status Codes:
  1829  
  1830  -   **200** – no error
  1831  -   **500** – server error
  1832  
  1833  ### Get a tarball containing all images.
  1834  
  1835  `GET /images/get`
  1836  
  1837  Get a tarball containing all images and metadata for one or more repositories.
  1838  
  1839  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  1840  ubuntu:latest), then only that image (and its parents) are returned; if it is
  1841  an image ID, similarly only that image (and its parents) are returned and there
  1842  would be no names referenced in the 'repositories' file for this image ID.
  1843  
  1844  See the [image tarball format](#image-tarball-format) for more details.
  1845  
  1846  **Example request**
  1847  
  1848          GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  1849  
  1850  **Example response**:
  1851  
  1852          HTTP/1.1 200 OK
  1853          Content-Type: application/x-tar
  1854  
  1855          Binary data stream
  1856  
  1857  Status Codes:
  1858  
  1859  -   **200** – no error
  1860  -   **500** – server error
  1861  
  1862  ### Load a tarball with a set of images and tags into docker
  1863  
  1864  `POST /images/load`
  1865  
  1866  Load a set of images and tags into the docker repository.
  1867  See the [image tarball format](#image-tarball-format) for more details.
  1868  
  1869  **Example request**
  1870  
  1871          POST /images/load
  1872  
  1873          Tarball in body
  1874  
  1875  **Example response**:
  1876  
  1877          HTTP/1.1 200 OK
  1878  
  1879  Status Codes:
  1880  
  1881  -   **200** – no error
  1882  -   **500** – server error
  1883  
  1884  ### Image tarball format
  1885  
  1886  An image tarball contains one directory per image layer (named using its long ID),
  1887  each containing three files:
  1888  
  1889  1. `VERSION`: currently `1.0` - the file format version
  1890  2. `json`: detailed layer information, similar to `docker inspect layer_id`
  1891  3. `layer.tar`: A tarfile containing the filesystem changes in this layer
  1892  
  1893  The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories
  1894  for storing attribute changes and deletions.
  1895  
  1896  If the tarball defines a repository, there will also be a `repositories` file at
  1897  the root that contains a list of repository and tag names mapped to layer IDs.
  1898  
  1899  ```
  1900  {"hello-world":
  1901      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  1902  }
  1903  ```
  1904  
  1905  ### Exec Create
  1906  
  1907  `POST /containers/(id)/exec`
  1908  
  1909  Sets up an exec instance in a running container `id`
  1910  
  1911  **Example request**:
  1912  
  1913          POST /containers/e90e34656806/exec HTTP/1.1
  1914          Content-Type: application/json
  1915  
  1916          {
  1917  	     "AttachStdin": false,
  1918  	     "AttachStdout": true,
  1919  	     "AttachStderr": true,
  1920  	     "Tty": false,
  1921  	     "Cmd": [
  1922                       "date"
  1923               ],
  1924          }
  1925  
  1926  **Example response**:
  1927  
  1928          HTTP/1.1 201 OK
  1929          Content-Type: application/json
  1930  
  1931          {
  1932               "Id": "f90e34656806"
  1933               "Warnings":[]
  1934          }
  1935  
  1936  Json Parameters:
  1937  
  1938  -   **AttachStdin** - Boolean value, attaches to stdin of the exec command.
  1939  -   **AttachStdout** - Boolean value, attaches to stdout of the exec command.
  1940  -   **AttachStderr** - Boolean value, attaches to stderr of the exec command.
  1941  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1942  -   **Cmd** - Command to run specified as a string or an array of strings.
  1943  
  1944  
  1945  Status Codes:
  1946  
  1947  -   **201** – no error
  1948  -   **404** – no such container
  1949  
  1950  ### Exec Start
  1951  
  1952  `POST /exec/(id)/start`
  1953  
  1954  Starts a previously set up exec instance `id`. If `detach` is true, this API
  1955  returns after starting the `exec` command. Otherwise, this API sets up an
  1956  interactive session with the `exec` command.
  1957  
  1958  **Example request**:
  1959  
  1960          POST /exec/e90e34656806/start HTTP/1.1
  1961          Content-Type: application/json
  1962  
  1963          {
  1964  	     "Detach": false,
  1965  	     "Tty": false,
  1966          }
  1967  
  1968  **Example response**:
  1969  
  1970          HTTP/1.1 201 OK
  1971          Content-Type: application/json
  1972  
  1973          {{ STREAM }}
  1974  
  1975  Json Parameters:
  1976  
  1977  -   **Detach** - Detach from the exec command
  1978  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1979  
  1980  Status Codes:
  1981  
  1982  -   **201** – no error
  1983  -   **404** – no such exec instance
  1984  
  1985      **Stream details**:
  1986      Similar to the stream behavior of `POST /container/(id)/attach` API
  1987  
  1988  ### Exec Resize
  1989  
  1990  `POST /exec/(id)/resize`
  1991  
  1992  Resizes the tty session used by the exec command `id`.
  1993  This API is valid only if `tty` was specified as part of creating and starting the exec command.
  1994  
  1995  **Example request**:
  1996  
  1997          POST /exec/e90e34656806/resize HTTP/1.1
  1998          Content-Type: text/plain
  1999  
  2000  **Example response**:
  2001  
  2002          HTTP/1.1 201 OK
  2003          Content-Type: text/plain
  2004  
  2005  Query Parameters:
  2006  
  2007  -   **h** – height of tty session
  2008  -   **w** – width
  2009  
  2010  Status Codes:
  2011  
  2012  -   **201** – no error
  2013  -   **404** – no such exec instance
  2014  
  2015  ### Exec Inspect
  2016  
  2017  `GET /exec/(id)/json`
  2018  
  2019  Return low-level information about the exec command `id`.
  2020  
  2021  **Example request**:
  2022  
  2023          GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  2024  
  2025  **Example response**:
  2026  
  2027          HTTP/1.1 200 OK
  2028          Content-Type: plain/text
  2029  
  2030          {
  2031            "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  2032            "Running" : false,
  2033            "ExitCode" : 2,
  2034            "ProcessConfig" : {
  2035              "privileged" : false,
  2036              "user" : "",
  2037              "tty" : false,
  2038              "entrypoint" : "sh",
  2039              "arguments" : [
  2040                "-c",
  2041                "exit 2"
  2042              ]
  2043            },
  2044            "OpenStdin" : false,
  2045            "OpenStderr" : false,
  2046            "OpenStdout" : false,
  2047            "Container" : {
  2048              "State" : {
  2049                "Running" : true,
  2050                "Paused" : false,
  2051                "Restarting" : false,
  2052                "OOMKilled" : false,
  2053                "Pid" : 3650,
  2054                "ExitCode" : 0,
  2055                "Error" : "",
  2056                "StartedAt" : "2014-11-17T22:26:03.717657531Z",
  2057                "FinishedAt" : "0001-01-01T00:00:00Z"
  2058              },
  2059              "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
  2060              "Created" : "2014-11-17T22:26:03.626304998Z",
  2061              "Path" : "date",
  2062              "Args" : [],
  2063              "Config" : {
  2064                "Hostname" : "8f177a186b97",
  2065                "Domainname" : "",
  2066                "User" : "",
  2067                "AttachStdin" : false,
  2068                "AttachStdout" : false,
  2069                "AttachStderr" : false,
  2070                "PortSpecs" : null,
  2071                "ExposedPorts" : null,
  2072                "Tty" : false,
  2073                "OpenStdin" : false,
  2074                "StdinOnce" : false,
  2075                "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
  2076                "Cmd" : [
  2077                  "date"
  2078                ],
  2079                "Image" : "ubuntu",
  2080                "Volumes" : null,
  2081                "WorkingDir" : "",
  2082                "Entrypoint" : null,
  2083                "NetworkDisabled" : false,
  2084                "MacAddress" : "",
  2085                "OnBuild" : null,
  2086                "SecurityOpt" : null
  2087              },
  2088              "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
  2089              "NetworkSettings" : {
  2090                "IPAddress" : "172.17.0.2",
  2091                "IPPrefixLen" : 16,
  2092                "MacAddress" : "02:42:ac:11:00:02",
  2093                "Gateway" : "172.17.42.1",
  2094                "Bridge" : "docker0",
  2095                "PortMapping" : null,
  2096                "Ports" : {}
  2097              },
  2098              "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
  2099              "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
  2100              "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
  2101              "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
  2102              "Name" : "/test",
  2103              "Driver" : "aufs",
  2104              "ExecDriver" : "native-0.2",
  2105              "MountLabel" : "",
  2106              "ProcessLabel" : "",
  2107              "AppArmorProfile" : "",
  2108              "RestartCount" : 0,
  2109              "Volumes" : {},
  2110              "VolumesRW" : {}
  2111            }
  2112          }
  2113  
  2114  Status Codes:
  2115  
  2116  -   **200** – no error
  2117  -   **404** – no such exec instance
  2118  -   **500** - server error
  2119  
  2120  # 3. Going further
  2121  
  2122  ## 3.1 Inside `docker run`
  2123  
  2124  As an example, the `docker run` command line makes the following API calls:
  2125  
  2126  - Create the container
  2127  
  2128  - If the status code is 404, it means the image doesn't exist:
  2129      - Try to pull it
  2130      - Then retry to create the container
  2131  
  2132  - Start the container
  2133  
  2134  - If you are not in detached mode:
  2135  - Attach to the container, using logs=1 (to have stdout and
  2136        stderr from the container's start) and stream=1
  2137  
  2138  - If in detached mode or only stdin is attached:
  2139  - Display the container's id
  2140  
  2141  ## 3.2 Hijacking
  2142  
  2143  In this version of the API, /attach, uses hijacking to transport stdin,
  2144  stdout and stderr on the same socket.
  2145  
  2146  To hint potential proxies about connection hijacking, Docker client sends
  2147  connection upgrade headers similarly to websocket.
  2148  
  2149      Upgrade: tcp
  2150      Connection: Upgrade
  2151  
  2152  When Docker daemon detects the `Upgrade` header, it will switch its status code
  2153  from **200 OK** to **101 UPGRADED** and resend the same headers.
  2154  
  2155  This might change in the future.
  2156  
  2157  ## 3.3 CORS Requests
  2158  
  2159  To set cross origin requests to the remote api please give values to 
  2160  "--api-cors-header" when running docker in daemon mode. Set * will allow all,
  2161  default or blank means CORS disabled
  2162  
  2163      $ docker -d -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"