github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/docs/reference/api/docker_remote_api_v1.16.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Remote API v1.16"
     4  description = "API Documentation for Docker"
     5  keywords = ["API, Docker, rcli, REST,  documentation"]
     6  [menu.main]
     7  parent = "engine_remoteapi"
     8  weight = 5
     9  +++
    10  <![end-metadata]-->
    11  
    12  # Docker Remote API v1.16
    13  
    14  ## 1. Brief introduction
    15  
    16   - The Remote API has replaced `rcli`.
    17   - The daemon listens on `unix:///var/run/docker.sock` but you can
    18     [Bind Docker to another host/port or a Unix socket](../../quickstart.md#bind-docker-to-another-host-port-or-a-unix-socket).
    19   - The API tends to be REST, but for some complex commands, like `attach`
    20     or `pull`, the HTTP connection is hijacked to transport `STDOUT`,
    21     `STDIN` and `STDERR`.
    22  
    23  # 2. Endpoints
    24  
    25  ## 2.1 Containers
    26  
    27  ### List containers
    28  
    29  `GET /containers/json`
    30  
    31  List containers
    32  
    33  **Example request**:
    34  
    35          GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
    36  
    37  **Example response**:
    38  
    39          HTTP/1.1 200 OK
    40          Content-Type: application/json
    41  
    42          [
    43               {
    44                       "Id": "8dfafdbc3a40",
    45                       "Names":["/boring_feynman"],
    46                       "Image": "ubuntu:latest",
    47                       "Command": "echo 1",
    48                       "Created": 1367854155,
    49                       "Status": "Exit 0",
    50                       "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
    51                       "SizeRw": 12288,
    52                       "SizeRootFs": 0
    53               },
    54               {
    55                       "Id": "9cd87474be90",
    56                       "Names":["/coolName"],
    57                       "Image": "ubuntu:latest",
    58                       "Command": "echo 222222",
    59                       "Created": 1367854155,
    60                       "Status": "Exit 0",
    61                       "Ports": [],
    62                       "SizeRw": 12288,
    63                       "SizeRootFs": 0
    64               },
    65               {
    66                       "Id": "3176a2479c92",
    67                       "Names":["/sleep_dog"],
    68                       "Image": "ubuntu:latest",
    69                       "Command": "echo 3333333333333333",
    70                       "Created": 1367854154,
    71                       "Status": "Exit 0",
    72                       "Ports":[],
    73                       "SizeRw":12288,
    74                       "SizeRootFs":0
    75               },
    76               {
    77                       "Id": "4cb07b47f9fb",
    78                       "Names":["/running_cat"],
    79                       "Image": "ubuntu:latest",
    80                       "Command": "echo 444444444444444444444444444444444",
    81                       "Created": 1367854152,
    82                       "Status": "Exit 0",
    83                       "Ports": [],
    84                       "SizeRw": 12288,
    85                       "SizeRootFs": 0
    86               }
    87          ]
    88  
    89  Query Parameters:
    90  
    91  -   **all** – 1/True/true or 0/False/false, Show all containers.
    92          Only running containers are shown by default (i.e., this defaults to false)
    93  -   **limit** – Show `limit` last created
    94          containers, include non-running ones.
    95  -   **since** – Show only containers created since Id, include
    96          non-running ones.
    97  -   **before** – Show only containers created before Id, include
    98          non-running ones.
    99  -   **size** – 1/True/true or 0/False/false, Show the containers
   100          sizes
   101  -   **filters** - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters:
   102    -   exited=&lt;int&gt; -- containers with exit code of &lt;int&gt;
   103    -   status=(restarting|running|paused|exited)
   104  
   105  Status Codes:
   106  
   107  -   **200** – no error
   108  -   **400** – bad parameter
   109  -   **500** – server error
   110  
   111  ### Create a container
   112  
   113  `POST /containers/create`
   114  
   115  Create a container
   116  
   117  **Example request**:
   118  
   119          POST /containers/create HTTP/1.1
   120          Content-Type: application/json
   121  
   122          {
   123               "Hostname": "",
   124               "Domainname": "",
   125               "User": "",
   126               "Memory": 0,
   127               "MemorySwap": 0,
   128               "CpuShares": 512,
   129               "Cpuset": "0,1",
   130               "AttachStdin": false,
   131               "AttachStdout": true,
   132               "AttachStderr": true,
   133               "Tty": false,
   134               "OpenStdin": false,
   135               "StdinOnce": false,
   136               "Env": [
   137                       "FOO=bar",
   138                       "BAZ=quux"
   139               ],
   140               "Cmd": [
   141                       "date"
   142               ],
   143               "Entrypoint": "",
   144               "Image": "ubuntu",
   145               "Volumes": {
   146                       "/tmp": {}
   147               },
   148               "WorkingDir": "",
   149               "NetworkDisabled": false,
   150               "MacAddress": "12:34:56:78:9a:bc",
   151               "ExposedPorts": {
   152                       "22/tcp": {}
   153               },
   154               "SecurityOpts": [],
   155               "HostConfig": {
   156                 "Binds": ["/tmp:/tmp"],
   157                 "Links": ["redis3:redis"],
   158                 "LxcConf": {"lxc.utsname":"docker"},
   159                 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
   160                 "PublishAllPorts": false,
   161                 "Privileged": false,
   162                 "Dns": ["8.8.8.8"],
   163                 "DnsSearch": [""],
   164                 "ExtraHosts": null,
   165                 "VolumesFrom": ["parent", "other:ro"],
   166                 "CapAdd": ["NET_ADMIN"],
   167                 "CapDrop": ["MKNOD"],
   168                 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
   169                 "NetworkMode": "bridge",
   170                 "Devices": []
   171              }
   172          }
   173  
   174  **Example response**:
   175  
   176          HTTP/1.1 201 Created
   177          Content-Type: application/json
   178  
   179          {
   180               "Id":"e90e34656806"
   181               "Warnings":[]
   182          }
   183  
   184  Json Parameters:
   185  
   186  -   **Hostname** - A string value containing the desired hostname to use for the
   187        container.
   188  -   **Domainname** - A string value containing the desired domain name to use
   189        for the container.
   190  -   **User** - A string value containing the user to use inside the container.
   191  -   **Memory** - Memory limit in bytes.
   192  -   **MemorySwap** - Total memory limit (memory + swap); set `-1` to enable unlimited swap.
   193  -   **CpuShares** - An integer value containing the CPU Shares for container
   194        (ie. the relative weight vs other containers).
   195      **CpuSet** - String value containing the cgroups Cpuset to use.
   196  -   **AttachStdin** - Boolean value, attaches to stdin.
   197  -   **AttachStdout** - Boolean value, attaches to stdout.
   198  -   **AttachStderr** - Boolean value, attaches to stderr.
   199  -   **Tty** - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.
   200  -   **OpenStdin** - Boolean value, opens stdin,
   201  -   **StdinOnce** - Boolean value, close stdin after the 1 attached client disconnects.
   202  -   **Env** - A list of environment variables in the form of `["VAR=value"[,"VAR2=value2"]]`
   203  -   **Cmd** - Command to run specified as a string or an array of strings.
   204  -   **Entrypoint** - Set the entrypoint for the container 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  -   **SecurityOpts**: A list of string values to customize labels for MLS
   216        systems, such as SELinux.
   217  -   **HostConfig**
   218    -   **Binds** – A list of volume bindings for this container.  Each volume
   219            binding is a string of the form `container_path` (to create a new
   220            volume for the container), `host_path:container_path` (to bind-mount
   221            a host path into the container), or `host_path:container_path:ro`
   222            (to make the bind-mount read-only inside the container).
   223    -   **Links** - A list of links for the container.  Each link entry should be
   224          in the form of "container_name:alias".
   225    -   **LxcConf** - LXC specific configurations.  These configurations will only
   226          work when using the `lxc` execution driver.
   227    -   **PortBindings** - A map of exposed container ports and the host port they
   228          should map to. It should be specified in the form
   229          `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
   230          Take note that `port` is specified as a string and not an integer value.
   231    -   **PublishAllPorts** - Allocates a random host port for all of a container's
   232          exposed ports. Specified as a boolean value.
   233    -   **Privileged** - Gives the container full access to the host.  Specified as
   234          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`, `none`, 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  
   257  Query Parameters:
   258  
   259  -   **name** – Assign the specified name to the container. Must
   260      match `/?[a-zA-Z0-9_-]+`.
   261  
   262  Status Codes:
   263  
   264  -   **201** – no error
   265  -   **404** – no such container
   266  -   **406** – impossible to attach (container not running)
   267  -   **500** – server error
   268  
   269  ### Inspect a container
   270  
   271  `GET /containers/(id or name)/json`
   272  
   273  Return low-level information on the container `id`
   274  
   275  
   276  **Example request**:
   277  
   278          GET /containers/4fa6e0f0c678/json HTTP/1.1
   279  
   280  **Example response**:
   281  
   282          HTTP/1.1 200 OK
   283          Content-Type: application/json
   284  
   285          {
   286                       "Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
   287                       "Created": "2013-05-07T14:51:42.041847+02:00",
   288                       "Path": "date",
   289                       "Args": [],
   290                       "Config": {
   291                               "Hostname": "4fa6e0f0c678",
   292                               "User": "",
   293                               "Memory": 0,
   294                               "MemorySwap": 0,
   295                               "AttachStdin": false,
   296                               "AttachStdout": true,
   297                               "AttachStderr": true,
   298                               "PortSpecs": null,
   299                               "Tty": false,
   300                               "OpenStdin": false,
   301                               "StdinOnce": false,
   302                               "Env": null,
   303                               "Cmd": [
   304                                       "date"
   305                               ],
   306                               "Dns": null,
   307                               "Image": "ubuntu",
   308                               "Volumes": {},
   309                               "VolumesFrom": "",
   310                               "WorkingDir": ""
   311                       },
   312                       "State": {
   313                               "Running": false,
   314                               "Pid": 0,
   315                               "ExitCode": 0,
   316                               "StartedAt": "2013-05-07T14:51:42.087658+02:01360",
   317                               "Ghost": false
   318                       },
   319                       "Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   320                       "NetworkSettings": {
   321                               "IpAddress": "",
   322                               "IpPrefixLen": 0,
   323                               "Gateway": "",
   324                               "Bridge": "",
   325                               "PortMapping": null
   326                       },
   327                       "SysInitPath": "/home/kitty/go/src/github.com/docker/docker/bin/docker",
   328                       "ResolvConfPath": "/etc/resolv.conf",
   329                       "Volumes": {},
   330                       "HostConfig": {
   331                           "Binds": null,
   332                           "ContainerIDFile": "",
   333                           "LxcConf": [],
   334                           "Privileged": false,
   335                           "PortBindings": {
   336                              "80/tcp": [
   337                                  {
   338                                      "HostIp": "0.0.0.0",
   339                                      "HostPort": "49153"
   340                                  }
   341                              ]
   342                           },
   343                           "Links": ["/name:alias"],
   344                           "PublishAllPorts": false,
   345                           "CapAdd": ["NET_ADMIN"],
   346                           "CapDrop": ["MKNOD"]
   347                       }
   348          }
   349  
   350  Status Codes:
   351  
   352  -   **200** – no error
   353  -   **404** – no such container
   354  -   **500** – server error
   355  
   356  ### List processes running inside a container
   357  
   358  `GET /containers/(id or name)/top`
   359  
   360  List processes running inside the container `id`. On Unix systems this
   361  is done by running the `ps` command. This endpoint is not
   362  supported on Windows.
   363  
   364  **Example request**:
   365  
   366      GET /containers/4fa6e0f0c678/top HTTP/1.1
   367  
   368  **Example response**:
   369  
   370      HTTP/1.1 200 OK
   371      Content-Type: application/json
   372  
   373      {
   374         "Titles" : [
   375           "UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD"
   376         ],
   377         "Processes" : [
   378           [
   379             "root", "13642", "882", "0", "17:03", "pts/0", "00:00:00", "/bin/bash"
   380           ],
   381           [
   382             "root", "13735", "13642", "0", "17:06", "pts/0", "00:00:00", "sleep 10"
   383           ]
   384         ]
   385      }
   386  
   387  **Example request**:
   388  
   389      GET /containers/4fa6e0f0c678/top?ps_args=aux HTTP/1.1
   390  
   391  **Example response**:
   392  
   393      HTTP/1.1 200 OK
   394      Content-Type: application/json
   395  
   396      {
   397        "Titles" : [
   398          "USER","PID","%CPU","%MEM","VSZ","RSS","TTY","STAT","START","TIME","COMMAND"
   399        ]
   400        "Processes" : [
   401          [
   402            "root","13642","0.0","0.1","18172","3184","pts/0","Ss","17:03","0:00","/bin/bash"
   403          ],
   404          [
   405            "root","13895","0.0","0.0","4348","692","pts/0","S+","17:15","0:00","sleep 10"
   406          ]
   407        ],
   408      }
   409  
   410  Query Parameters:
   411  
   412  -   **ps_args** – `ps` arguments to use (e.g., `aux`), defaults to `-ef`
   413  
   414  Status Codes:
   415  
   416  -   **200** – no error
   417  -   **404** – no such container
   418  -   **500** – server error
   419  
   420  ### Get container logs
   421  
   422  `GET /containers/(id or name)/logs`
   423  
   424  Get stdout and stderr logs from the container ``id``
   425  
   426  **Example request**:
   427  
   428         GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1&timestamps=1&follow=1&tail=10 HTTP/1.1
   429  
   430  **Example response**:
   431  
   432         HTTP/1.1 200 OK
   433         Content-Type: application/vnd.docker.raw-stream
   434  
   435         {{ STREAM }}
   436  
   437  Query Parameters:
   438  
   439  -   **follow** – 1/True/true or 0/False/false, return stream. Default false
   440  -   **stdout** – 1/True/true or 0/False/false, show stdout log. Default false
   441  -   **stderr** – 1/True/true or 0/False/false, show stderr log. Default false
   442  -   **timestamps** – 1/True/true or 0/False/false, print timestamps for
   443          every log line. Default false
   444  -   **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all
   445  
   446  Status Codes:
   447  
   448  -   **200** – no error
   449  -   **404** – no such container
   450  -   **500** – server error
   451  
   452  ### Inspect changes on a container's filesystem
   453  
   454  `GET /containers/(id or name)/changes`
   455  
   456  Inspect changes on container `id`'s filesystem
   457  
   458  **Example request**:
   459  
   460          GET /containers/4fa6e0f0c678/changes HTTP/1.1
   461  
   462  **Example response**:
   463  
   464          HTTP/1.1 200 OK
   465          Content-Type: application/json
   466  
   467          [
   468               {
   469                       "Path": "/dev",
   470                       "Kind": 0
   471               },
   472               {
   473                       "Path": "/dev/kmsg",
   474                       "Kind": 1
   475               },
   476               {
   477                       "Path": "/test",
   478                       "Kind": 1
   479               }
   480          ]
   481  
   482  Status Codes:
   483  
   484  -   **200** – no error
   485  -   **404** – no such container
   486  -   **500** – server error
   487  
   488  ### Export a container
   489  
   490  `GET /containers/(id or name)/export`
   491  
   492  Export the contents of container `id`
   493  
   494  **Example request**:
   495  
   496          GET /containers/4fa6e0f0c678/export HTTP/1.1
   497  
   498  **Example response**:
   499  
   500          HTTP/1.1 200 OK
   501          Content-Type: application/octet-stream
   502  
   503          {{ TAR STREAM }}
   504  
   505  Status Codes:
   506  
   507  -   **200** – no error
   508  -   **404** – no such container
   509  -   **500** – server error
   510  
   511  ### Resize a container TTY
   512  
   513  `POST /containers/(id or name)/resize?h=<height>&w=<width>`
   514  
   515  Resize the TTY for container with  `id`. The container must be restarted for the resize to take effect.
   516  
   517  **Example request**:
   518  
   519          POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
   520  
   521  **Example response**:
   522  
   523          HTTP/1.1 200 OK
   524          Content-Length: 0
   525          Content-Type: text/plain; charset=utf-8
   526  
   527  Status Codes:
   528  
   529  -   **200** – no error
   530  -   **404** – No such container
   531  -   **500** – Cannot resize container
   532  
   533  ### Start a container
   534  
   535  `POST /containers/(id or name)/start`
   536  
   537  Start the container `id`
   538  
   539  > **Note**:
   540  > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body.
   541  > See [create a container](#create-a-container) for details.
   542  
   543  **Example request**:
   544  
   545          POST /containers/e90e34656806/start HTTP/1.1
   546  
   547  **Example response**:
   548  
   549          HTTP/1.1 204 No Content
   550  
   551  Status Codes:
   552  
   553  -   **204** – no error
   554  -   **304** – container already started
   555  -   **404** – no such container
   556  -   **500** – server error
   557  
   558  ### Stop a container
   559  
   560  `POST /containers/(id or name)/stop`
   561  
   562  Stop the container `id`
   563  
   564  **Example request**:
   565  
   566          POST /containers/e90e34656806/stop?t=5 HTTP/1.1
   567  
   568  **Example response**:
   569  
   570          HTTP/1.1 204 No Content
   571  
   572  Query Parameters:
   573  
   574  -   **t** – number of seconds to wait before killing the container
   575  
   576  Status Codes:
   577  
   578  -   **204** – no error
   579  -   **304** – container already stopped
   580  -   **404** – no such container
   581  -   **500** – server error
   582  
   583  ### Restart a container
   584  
   585  `POST /containers/(id or name)/restart`
   586  
   587  Restart the container `id`
   588  
   589  **Example request**:
   590  
   591          POST /containers/e90e34656806/restart?t=5 HTTP/1.1
   592  
   593  **Example response**:
   594  
   595          HTTP/1.1 204 No Content
   596  
   597  Query Parameters:
   598  
   599  -   **t** – number of seconds to wait before killing the container
   600  
   601  Status Codes:
   602  
   603  -   **204** – no error
   604  -   **404** – no such container
   605  -   **500** – server error
   606  
   607  ### Kill a container
   608  
   609  `POST /containers/(id or name)/kill`
   610  
   611  Kill the container `id`
   612  
   613  **Example request**:
   614  
   615          POST /containers/e90e34656806/kill HTTP/1.1
   616  
   617  **Example response**:
   618  
   619          HTTP/1.1 204 No Content
   620  
   621  Query Parameters
   622  
   623  -   **signal** - Signal to send to the container: integer or string like "SIGINT".
   624          When not set, SIGKILL is assumed and the call will waits for the container to exit.
   625  
   626  Status Codes:
   627  
   628  -   **204** – no error
   629  -   **404** – no such container
   630  -   **500** – server error
   631  
   632  ### Pause a container
   633  
   634  `POST /containers/(id or name)/pause`
   635  
   636  Pause the container `id`
   637  
   638  **Example request**:
   639  
   640          POST /containers/e90e34656806/pause HTTP/1.1
   641  
   642  **Example response**:
   643  
   644          HTTP/1.1 204 No Content
   645  
   646  Status Codes:
   647  
   648  -   **204** – no error
   649  -   **404** – no such container
   650  -   **500** – server error
   651  
   652  ### Unpause a container
   653  
   654  `POST /containers/(id or name)/unpause`
   655  
   656  Unpause the container `id`
   657  
   658  **Example request**:
   659  
   660          POST /containers/e90e34656806/unpause HTTP/1.1
   661  
   662  **Example response**:
   663  
   664          HTTP/1.1 204 No Content
   665  
   666  Status Codes:
   667  
   668  -   **204** – no error
   669  -   **404** – no such container
   670  -   **500** – server error
   671  
   672  ### Attach to a container
   673  
   674  `POST /containers/(id or name)/attach`
   675  
   676  Attach to the container `id`
   677  
   678  **Example request**:
   679  
   680          POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
   681  
   682  **Example response**:
   683  
   684          HTTP/1.1 200 OK
   685          Content-Type: application/vnd.docker.raw-stream
   686  
   687          {{ STREAM }}
   688  
   689  Query Parameters:
   690  
   691  -   **logs** – 1/True/true or 0/False/false, return logs. Default false
   692  -   **stream** – 1/True/true or 0/False/false, return stream.
   693          Default false
   694  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   695          to stdin. Default false
   696  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   697          stdout log, if stream=true, attach to stdout. Default false
   698  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   699          stderr log, if stream=true, attach to stderr. Default false
   700  
   701  Status Codes:
   702  
   703  -   **200** – no error
   704  -   **400** – bad parameter
   705  -   **404** – no such container
   706  -   **500** – server error
   707  
   708      **Stream details**:
   709  
   710      When using the TTY setting is enabled in
   711      [`POST /containers/create`
   712      ](#create-a-container),
   713      the stream is the raw data from the process PTY and client's stdin.
   714      When the TTY is disabled, then the stream is multiplexed to separate
   715      stdout and stderr.
   716  
   717      The format is a **Header** and a **Payload** (frame).
   718  
   719      **HEADER**
   720  
   721      The header will contain the information on which stream write the
   722      stream (stdout or stderr). It also contain the size of the
   723      associated frame encoded on the last 4 bytes (uint32).
   724  
   725      It is encoded on the first 8 bytes like this:
   726  
   727          header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
   728  
   729      `STREAM_TYPE` can be:
   730  
   731  -   0: stdin (will be written on stdout)
   732  -   1: stdout
   733  -   2: stderr
   734  
   735      `SIZE1, SIZE2, SIZE3, SIZE4` are the 4 bytes of
   736      the uint32 size encoded as big endian.
   737  
   738      **PAYLOAD**
   739  
   740      The payload is the raw stream.
   741  
   742      **IMPLEMENTATION**
   743  
   744      The simplest way to implement the Attach protocol is the following:
   745  
   746      1.  Read 8 bytes
   747      2.  chose stdout or stderr depending on the first byte
   748      3.  Extract the frame size from the last 4 bytes
   749      4.  Read the extracted size and output it on the correct output
   750      5.  Goto 1
   751  
   752  ### Attach to a container (websocket)
   753  
   754  `GET /containers/(id or name)/attach/ws`
   755  
   756  Attach to the container `id` via websocket
   757  
   758  Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
   759  
   760  **Example request**
   761  
   762          GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
   763  
   764  **Example response**
   765  
   766          {{ STREAM }}
   767  
   768  Query Parameters:
   769  
   770  -   **logs** – 1/True/true or 0/False/false, return logs. Default false
   771  -   **stream** – 1/True/true or 0/False/false, return stream.
   772          Default false
   773  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   774          to stdin. Default false
   775  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   776          stdout log, if stream=true, attach to stdout. Default false
   777  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   778          stderr log, if stream=true, attach to stderr. Default false
   779  
   780  Status Codes:
   781  
   782  -   **200** – no error
   783  -   **400** – bad parameter
   784  -   **404** – no such container
   785  -   **500** – server error
   786  
   787  ### Wait a container
   788  
   789  `POST /containers/(id or name)/wait`
   790  
   791  Block until container `id` stops, then returns the exit code
   792  
   793  **Example request**:
   794  
   795          POST /containers/16253994b7c4/wait HTTP/1.1
   796  
   797  **Example response**:
   798  
   799          HTTP/1.1 200 OK
   800          Content-Type: application/json
   801  
   802          {"StatusCode": 0}
   803  
   804  Status Codes:
   805  
   806  -   **200** – no error
   807  -   **404** – no such container
   808  -   **500** – server error
   809  
   810  ### Remove a container
   811  
   812  `DELETE /containers/(id or name)`
   813  
   814  Remove the container `id` from the filesystem
   815  
   816  **Example request**:
   817  
   818          DELETE /containers/16253994b7c4?v=1 HTTP/1.1
   819  
   820  **Example response**:
   821  
   822          HTTP/1.1 204 No Content
   823  
   824  Query Parameters:
   825  
   826  -   **v** – 1/True/true or 0/False/false, Remove the volumes
   827          associated to the container. Default false
   828  -   **force** - 1/True/true or 0/False/false, Kill then remove the container.
   829          Default false
   830  
   831  Status Codes:
   832  
   833  -   **204** – no error
   834  -   **400** – bad parameter
   835  -   **404** – no such container
   836  -   **500** – server error
   837  
   838  ### Copy files or folders from a container
   839  
   840  `POST /containers/(id or name)/copy`
   841  
   842  Copy files or folders of container `id`
   843  
   844  **Example request**:
   845  
   846          POST /containers/4fa6e0f0c678/copy HTTP/1.1
   847          Content-Type: application/json
   848  
   849          {
   850               "Resource": "test.txt"
   851          }
   852  
   853  **Example response**:
   854  
   855          HTTP/1.1 200 OK
   856          Content-Type: application/x-tar
   857  
   858          {{ TAR STREAM }}
   859  
   860  Status Codes:
   861  
   862  -   **200** – no error
   863  -   **404** – no such container
   864  -   **500** – server error
   865  
   866  ## 2.2 Images
   867  
   868  ### List Images
   869  
   870  `GET /images/json`
   871  
   872  **Example request**:
   873  
   874          GET /images/json?all=0 HTTP/1.1
   875  
   876  **Example response**:
   877  
   878          HTTP/1.1 200 OK
   879          Content-Type: application/json
   880  
   881          [
   882            {
   883               "RepoTags": [
   884                 "ubuntu:12.04",
   885                 "ubuntu:precise",
   886                 "ubuntu:latest"
   887               ],
   888               "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
   889               "Created": 1365714795,
   890               "Size": 131506275,
   891               "VirtualSize": 131506275
   892            },
   893            {
   894               "RepoTags": [
   895                 "ubuntu:12.10",
   896                 "ubuntu:quantal"
   897               ],
   898               "ParentId": "27cf784147099545",
   899               "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   900               "Created": 1364102658,
   901               "Size": 24653,
   902               "VirtualSize": 180116135
   903            }
   904          ]
   905  
   906  
   907  Query Parameters:
   908  
   909  -   **all** – 1/True/true or 0/False/false, default false
   910  -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
   911    -   dangling=true
   912  -   **filter** - only return images with the specified name
   913  
   914  ### Create an image
   915  
   916  `POST /images/create`
   917  
   918  Create an image, either by pulling it from the registry or by importing it
   919  
   920  **Example request**:
   921  
   922          POST /images/create?fromImage=ubuntu HTTP/1.1
   923  
   924  **Example response**:
   925  
   926          HTTP/1.1 200 OK
   927          Content-Type: application/json
   928  
   929          {"status": "Pulling..."}
   930          {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
   931          {"error": "Invalid..."}
   932          ...
   933  
   934      When using this endpoint to pull an image from the registry, the
   935      `X-Registry-Auth` header can be used to include
   936      a base64-encoded AuthConfig object.
   937  
   938  Query Parameters:
   939  
   940  -   **fromImage** – name of the image to pull
   941  -   **fromSrc** – source to import.  The value may be a URL from which the image
   942          can be retrieved or `-` to read the image from the request body.
   943  -   **repo** – repository
   944  -   **tag** – tag
   945  -   **registry** – the registry to pull from
   946  
   947      Request Headers:
   948  
   949  -   **X-Registry-Auth** – base64-encoded AuthConfig object
   950  
   951  Status Codes:
   952  
   953  -   **200** – no error
   954  -   **500** – server error
   955  
   956  
   957  
   958  ### Inspect an image
   959  
   960  `GET /images/(name)/json`
   961  
   962  Return low-level information on the image `name`
   963  
   964  **Example request**:
   965  
   966          GET /images/ubuntu/json HTTP/1.1
   967  
   968  **Example response**:
   969  
   970          HTTP/1.1 200 OK
   971          Content-Type: application/json
   972  
   973          {
   974               "Created": "2013-03-23T22:24:18.818426-07:00",
   975               "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
   976               "ContainerConfig":
   977                       {
   978                               "Hostname": "",
   979                               "User": "",
   980                               "Memory": 0,
   981                               "MemorySwap": 0,
   982                               "AttachStdin": false,
   983                               "AttachStdout": false,
   984                               "AttachStderr": false,
   985                               "PortSpecs": null,
   986                               "Tty": true,
   987                               "OpenStdin": true,
   988                               "StdinOnce": false,
   989                               "Env": null,
   990                               "Cmd": ["/bin/bash"],
   991                               "Dns": null,
   992                               "Image": "ubuntu",
   993                               "Volumes": null,
   994                               "VolumesFrom": "",
   995                               "WorkingDir": ""
   996                       },
   997               "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   998               "Parent": "27cf784147099545",
   999               "Size": 6824592
  1000          }
  1001  
  1002  Status Codes:
  1003  
  1004  -   **200** – no error
  1005  -   **404** – no such image
  1006  -   **500** – server error
  1007  
  1008  ### Get the history of an image
  1009  
  1010  `GET /images/(name)/history`
  1011  
  1012  Return the history of the image `name`
  1013  
  1014  **Example request**:
  1015  
  1016          GET /images/ubuntu/history HTTP/1.1
  1017  
  1018  **Example response**:
  1019  
  1020          HTTP/1.1 200 OK
  1021          Content-Type: application/json
  1022  
  1023          [
  1024               {
  1025                       "Id": "b750fe79269d",
  1026                       "Created": 1364102658,
  1027                       "CreatedBy": "/bin/bash"
  1028               },
  1029               {
  1030                       "Id": "27cf78414709",
  1031                       "Created": 1364068391,
  1032                       "CreatedBy": ""
  1033               }
  1034          ]
  1035  
  1036  Status Codes:
  1037  
  1038  -   **200** – no error
  1039  -   **404** – no such image
  1040  -   **500** – server error
  1041  
  1042  ### Push an image on the registry
  1043  
  1044  `POST /images/(name)/push`
  1045  
  1046  Push the image `name` on the registry
  1047  
  1048  **Example request**:
  1049  
  1050          POST /images/test/push HTTP/1.1
  1051  
  1052  **Example response**:
  1053  
  1054          HTTP/1.1 200 OK
  1055          Content-Type: application/json
  1056  
  1057          {"status": "Pushing..."}
  1058          {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
  1059          {"error": "Invalid..."}
  1060          ...
  1061  
  1062      If you wish to push an image on to a private registry, that image must already have been tagged
  1063      into a repository which references that registry host name and port.  This repository name should
  1064      then be used in the URL. This mirrors the flow of the CLI.
  1065  
  1066  **Example request**:
  1067  
  1068          POST /images/registry.acme.com:5000/test/push HTTP/1.1
  1069  
  1070  
  1071  Query Parameters:
  1072  
  1073  -   **tag** – the tag to associate with the image on the registry, optional
  1074  
  1075  Request Headers:
  1076  
  1077  -   **X-Registry-Auth** – include a base64-encoded AuthConfig
  1078          object.
  1079  
  1080  Status Codes:
  1081  
  1082  -   **200** – no error
  1083  -   **404** – no such image
  1084  -   **500** – server error
  1085  
  1086  ### Tag an image into a repository
  1087  
  1088  `POST /images/(name)/tag`
  1089  
  1090  Tag the image `name` into a repository
  1091  
  1092  **Example request**:
  1093  
  1094          POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
  1095  
  1096  **Example response**:
  1097  
  1098          HTTP/1.1 201 Created
  1099  
  1100  Query Parameters:
  1101  
  1102  -   **repo** – The repository to tag in
  1103  -   **force** – 1/True/true or 0/False/false, default false
  1104  -   **tag** - The new tag name
  1105  
  1106  Status Codes:
  1107  
  1108  -   **201** – no error
  1109  -   **400** – bad parameter
  1110  -   **404** – no such image
  1111  -   **409** – conflict
  1112  -   **500** – server error
  1113  
  1114  ### Remove an image
  1115  
  1116  `DELETE /images/(name)`
  1117  
  1118  Remove the image `name` from the filesystem
  1119  
  1120  **Example request**:
  1121  
  1122          DELETE /images/test HTTP/1.1
  1123  
  1124  **Example response**:
  1125  
  1126          HTTP/1.1 200 OK
  1127          Content-type: application/json
  1128  
  1129          [
  1130           {"Untagged": "3e2f21a89f"},
  1131           {"Deleted": "3e2f21a89f"},
  1132           {"Deleted": "53b4f83ac9"}
  1133          ]
  1134  
  1135  Query Parameters:
  1136  
  1137  -   **force** – 1/True/true or 0/False/false, default false
  1138  -   **noprune** – 1/True/true or 0/False/false, default false
  1139  
  1140  Status Codes:
  1141  
  1142  -   **200** – no error
  1143  -   **404** – no such image
  1144  -   **409** – conflict
  1145  -   **500** – server error
  1146  
  1147  ### Search images
  1148  
  1149  `GET /images/search`
  1150  
  1151  Search for an image on [Docker Hub](https://hub.docker.com).
  1152  
  1153  > **Note**:
  1154  > The response keys have changed from API v1.6 to reflect the JSON
  1155  > sent by the registry server to the docker daemon's request.
  1156  
  1157  **Example request**:
  1158  
  1159          GET /images/search?term=sshd HTTP/1.1
  1160  
  1161  **Example response**:
  1162  
  1163          HTTP/1.1 200 OK
  1164          Content-Type: application/json
  1165  
  1166          [
  1167                  {
  1168                      "description": "",
  1169                      "is_official": false,
  1170                      "is_automated": false,
  1171                      "name": "wma55/u1210sshd",
  1172                      "star_count": 0
  1173                  },
  1174                  {
  1175                      "description": "",
  1176                      "is_official": false,
  1177                      "is_automated": false,
  1178                      "name": "jdswinbank/sshd",
  1179                      "star_count": 0
  1180                  },
  1181                  {
  1182                      "description": "",
  1183                      "is_official": false,
  1184                      "is_automated": false,
  1185                      "name": "vgauthier/sshd",
  1186                      "star_count": 0
  1187                  }
  1188          ...
  1189          ]
  1190  
  1191  Query Parameters:
  1192  
  1193  -   **term** – term to search
  1194  
  1195  Status Codes:
  1196  
  1197  -   **200** – no error
  1198  -   **500** – server error
  1199  
  1200  ## 2.3 Misc
  1201  
  1202  ### Build an image from Dockerfile via stdin
  1203  
  1204  `POST /build`
  1205  
  1206  Build an image from Dockerfile via stdin
  1207  
  1208  **Example request**:
  1209  
  1210          POST /build HTTP/1.1
  1211  
  1212          {{ TAR STREAM }}
  1213  
  1214  **Example response**:
  1215  
  1216          HTTP/1.1 200 OK
  1217          Content-Type: application/json
  1218  
  1219          {"stream": "Step 1..."}
  1220          {"stream": "..."}
  1221          {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
  1222  
  1223      The stream must be a tar archive compressed with one of the
  1224      following algorithms: identity (no compression), gzip, bzip2, xz.
  1225  
  1226      The archive must include a file called `Dockerfile`
  1227      at its root. It may include any number of other files,
  1228      which will be accessible in the build context (See the [*ADD build
  1229      command*](../../reference/builder.md#dockerbuilder)).
  1230  
  1231  Query Parameters:
  1232  
  1233  -   **t** – repository name (and optionally a tag) to be applied to
  1234          the resulting image in case of success
  1235  -   **remote** – git or HTTP/HTTPS URI build source
  1236  -   **q** – suppress verbose build output
  1237  -   **nocache** – do not use the cache when building the image
  1238  -   **pull** - attempt to pull the image even if an older image exists locally
  1239  -   **rm** - remove intermediate containers after a successful build (default behavior)
  1240  -   **forcerm** - always remove intermediate containers (includes rm)
  1241  
  1242      Request Headers:
  1243  
  1244  -   **Content-type** – should be set to `"application/tar"`.
  1245  -   **X-Registry-Config** – base64-encoded ConfigFile object
  1246  
  1247  Status Codes:
  1248  
  1249  -   **200** – no error
  1250  -   **500** – server error
  1251  
  1252  ### Check auth configuration
  1253  
  1254  `POST /auth`
  1255  
  1256  Get the default username and email
  1257  
  1258  **Example request**:
  1259  
  1260          POST /auth HTTP/1.1
  1261          Content-Type: application/json
  1262  
  1263          {
  1264               "username":" hannibal",
  1265               "password: "xxxx",
  1266               "email": "hannibal@a-team.com",
  1267               "serveraddress": "https://index.docker.io/v1/"
  1268          }
  1269  
  1270  **Example response**:
  1271  
  1272          HTTP/1.1 200 OK
  1273  
  1274  Status Codes:
  1275  
  1276  -   **200** – no error
  1277  -   **204** – no error
  1278  -   **500** – server error
  1279  
  1280  ### Display system-wide information
  1281  
  1282  `GET /info`
  1283  
  1284  Display system-wide information
  1285  
  1286  **Example request**:
  1287  
  1288          GET /info HTTP/1.1
  1289  
  1290  **Example response**:
  1291  
  1292          HTTP/1.1 200 OK
  1293          Content-Type: application/json
  1294  
  1295          {
  1296               "Containers":11,
  1297               "Images":16,
  1298               "Driver":"btrfs",
  1299               "DriverStatus": [[""]],
  1300               "ExecutionDriver":"native-0.1",
  1301               "KernelVersion":"3.12.0-1-amd64"
  1302               "NCPU":1,
  1303               "MemTotal":2099236864,
  1304               "Name":"prod-server-42",
  1305               "ID":"7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  1306               "Debug":false,
  1307               "NFd": 11,
  1308               "NGoroutines":21,
  1309               "NEventsListener":0,
  1310               "InitPath":"/usr/bin/docker",
  1311               "InitSha1":"",
  1312               "IndexServerAddress":["https://index.docker.io/v1/"],
  1313               "MemoryLimit":true,
  1314               "SwapLimit":false,
  1315               "IPv4Forwarding":true,
  1316               "Labels":["storage=ssd"],
  1317               "DockerRootDir": "/var/lib/docker",
  1318               "OperatingSystem": "Boot2Docker",
  1319          }
  1320  
  1321  Status Codes:
  1322  
  1323  -   **200** – no error
  1324  -   **500** – server error
  1325  
  1326  ### Show the docker version information
  1327  
  1328  `GET /version`
  1329  
  1330  Show the docker version information
  1331  
  1332  **Example request**:
  1333  
  1334          GET /version HTTP/1.1
  1335  
  1336  **Example response**:
  1337  
  1338          HTTP/1.1 200 OK
  1339          Content-Type: application/json
  1340  
  1341          {
  1342               "ApiVersion": "1.12",
  1343               "Version": "0.2.2",
  1344               "GitCommit": "5a2a5cc+CHANGES",
  1345               "GoVersion": "go1.0.3"
  1346          }
  1347  
  1348  Status Codes:
  1349  
  1350  -   **200** – no error
  1351  -   **500** – server error
  1352  
  1353  ### Ping the docker server
  1354  
  1355  `GET /_ping`
  1356  
  1357  Ping the docker server
  1358  
  1359  **Example request**:
  1360  
  1361          GET /_ping HTTP/1.1
  1362  
  1363  **Example response**:
  1364  
  1365          HTTP/1.1 200 OK
  1366          Content-Type: text/plain
  1367  
  1368          OK
  1369  
  1370  Status Codes:
  1371  
  1372  -   **200** - no error
  1373  -   **500** - server error
  1374  
  1375  ### Create a new image from a container's changes
  1376  
  1377  `POST /commit`
  1378  
  1379  Create a new image from a container's changes
  1380  
  1381  **Example request**:
  1382  
  1383          POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1384          Content-Type: application/json
  1385  
  1386          {
  1387               "Hostname": "",
  1388               "Domainname": "",
  1389               "User": "",
  1390               "Memory": 0,
  1391               "MemorySwap": 0,
  1392               "CpuShares": 512,
  1393               "Cpuset": "0,1",
  1394               "AttachStdin": false,
  1395               "AttachStdout": true,
  1396               "AttachStderr": true,
  1397               "PortSpecs": null,
  1398               "Tty": false,
  1399               "OpenStdin": false,
  1400               "StdinOnce": false,
  1401               "Env": null,
  1402               "Cmd": [
  1403                       "date"
  1404               ],
  1405               "Volumes": {
  1406                       "/tmp": {}
  1407               },
  1408               "WorkingDir": "",
  1409               "NetworkDisabled": false,
  1410               "ExposedPorts": {
  1411                       "22/tcp": {}
  1412               }
  1413          }
  1414  
  1415  **Example response**:
  1416  
  1417          HTTP/1.1 201 Created
  1418          Content-Type: application/json
  1419  
  1420          {"Id": "596069db4bf5"}
  1421  
  1422  Json Parameters:
  1423  
  1424  -  **config** - the container's configuration
  1425  
  1426  Query Parameters:
  1427  
  1428  -   **container** – source container
  1429  -   **repo** – repository
  1430  -   **tag** – tag
  1431  -   **comment** – commit message
  1432  -   **author** – author (e.g., "John Hannibal Smith
  1433      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1434  
  1435  Status Codes:
  1436  
  1437  -   **201** – no error
  1438  -   **404** – no such container
  1439  -   **500** – server error
  1440  
  1441  ### Monitor Docker's events
  1442  
  1443  `GET /events`
  1444  
  1445  Get container events from docker, either in real time via streaming, or via
  1446  polling (using since).
  1447  
  1448  Docker containers will report the following events:
  1449  
  1450      create, destroy, die, export, kill, pause, restart, start, stop, unpause
  1451  
  1452  and Docker images will report:
  1453  
  1454      untag, delete
  1455  
  1456  **Example request**:
  1457  
  1458          GET /events?since=1374067924
  1459  
  1460  **Example response**:
  1461  
  1462          HTTP/1.1 200 OK
  1463          Content-Type: application/json
  1464  
  1465          {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1466          {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1467          {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1468          {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1469  
  1470  Query Parameters:
  1471  
  1472  -   **since** – timestamp used for polling
  1473  -   **until** – timestamp used for polling
  1474  -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  1475    -   event=&lt;string&gt; -- event to filter
  1476    -   image=&lt;string&gt; -- image to filter
  1477    -   container=&lt;string&gt; -- container to filter
  1478  
  1479  Status Codes:
  1480  
  1481  -   **200** – no error
  1482  -   **500** – server error
  1483  
  1484  ### Get a tarball containing all images in a repository
  1485  
  1486  `GET /images/(name)/get`
  1487  
  1488  Get a tarball containing all images and metadata for the repository specified
  1489  by `name`.
  1490  
  1491  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  1492  (and its parents) are returned. If `name` is an image ID, similarly only that
  1493  image (and its parents) are returned, but with the exclusion of the
  1494  'repositories' file in the tarball, as there were no image names referenced.
  1495  
  1496  See the [image tarball format](#image-tarball-format) for more details.
  1497  
  1498  **Example request**
  1499  
  1500          GET /images/ubuntu/get
  1501  
  1502  **Example response**:
  1503  
  1504          HTTP/1.1 200 OK
  1505          Content-Type: application/x-tar
  1506  
  1507          Binary data stream
  1508  
  1509  Status Codes:
  1510  
  1511  -   **200** – no error
  1512  -   **500** – server error
  1513  
  1514  ### Get a tarball containing all images.
  1515  
  1516  `GET /images/get`
  1517  
  1518  Get a tarball containing all images and metadata for one or more repositories.
  1519  
  1520  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  1521  ubuntu:latest), then only that image (and its parents) are returned; if it is
  1522  an image ID, similarly only that image (and its parents) are returned and there
  1523  would be no names referenced in the 'repositories' file for this image ID.
  1524  
  1525  See the [image tarball format](#image-tarball-format) for more details.
  1526  
  1527  **Example request**
  1528  
  1529          GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  1530  
  1531  **Example response**:
  1532  
  1533          HTTP/1.1 200 OK
  1534          Content-Type: application/x-tar
  1535  
  1536          Binary data stream
  1537  
  1538  Status Codes:
  1539  
  1540  -   **200** – no error
  1541  -   **500** – server error
  1542  
  1543  ### Load a tarball with a set of images and tags into docker
  1544  
  1545  `POST /images/load`
  1546  
  1547  Load a set of images and tags into the docker repository.
  1548  See the [image tarball format](#image-tarball-format) for more details.
  1549  
  1550  **Example request**
  1551  
  1552          POST /images/load
  1553  
  1554          Tarball in body
  1555  
  1556  **Example response**:
  1557  
  1558          HTTP/1.1 200 OK
  1559  
  1560  Status Codes:
  1561  
  1562  -   **200** – no error
  1563  -   **500** – server error
  1564  
  1565  ### Image tarball format
  1566  
  1567  An image tarball contains one directory per image layer (named using its long ID),
  1568  each containing three files:
  1569  
  1570  1. `VERSION`: currently `1.0` - the file format version
  1571  2. `json`: detailed layer information, similar to `docker inspect layer_id`
  1572  3. `layer.tar`: A tarfile containing the filesystem changes in this layer
  1573  
  1574  The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories
  1575  for storing attribute changes and deletions.
  1576  
  1577  If the tarball defines a repository, there will also be a `repositories` file at
  1578  the root that contains a list of repository and tag names mapped to layer IDs.
  1579  
  1580  ```
  1581  {"hello-world":
  1582      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  1583  }
  1584  ```
  1585  
  1586  ### Exec Create
  1587  
  1588  `POST /containers/(id or name)/exec`
  1589  
  1590  Sets up an exec instance in a running container `id`
  1591  
  1592  **Example request**:
  1593  
  1594          POST /containers/e90e34656806/exec HTTP/1.1
  1595          Content-Type: application/json
  1596  
  1597          {
  1598  	     "AttachStdin": false,
  1599  	     "AttachStdout": true,
  1600  	     "AttachStderr": true,
  1601  	     "Tty": false,
  1602  	     "Cmd": [
  1603                       "date"
  1604               ],
  1605          }
  1606  
  1607  **Example response**:
  1608  
  1609          HTTP/1.1 201 Created
  1610          Content-Type: application/json
  1611  
  1612          {
  1613               "Id": "f90e34656806"
  1614          }
  1615  
  1616  Json Parameters:
  1617  
  1618  -   **AttachStdin** - Boolean value, attaches to stdin of the exec command.
  1619  -   **AttachStdout** - Boolean value, attaches to stdout of the exec command.
  1620  -   **AttachStderr** - Boolean value, attaches to stderr of the exec command.
  1621  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1622  -   **Cmd** - Command to run specified as a string or an array of strings.
  1623  
  1624  
  1625  Status Codes:
  1626  
  1627  -   **201** – no error
  1628  -   **404** – no such container
  1629  
  1630  ### Exec Start
  1631  
  1632  `POST /exec/(id)/start`
  1633  
  1634  Starts a previously set up exec instance `id`. If `detach` is true, this API
  1635  returns after starting the `exec` command. Otherwise, this API sets up an
  1636  interactive session with the `exec` command.
  1637  
  1638  **Example request**:
  1639  
  1640          POST /exec/e90e34656806/start HTTP/1.1
  1641          Content-Type: application/json
  1642  
  1643          {
  1644  	     "Detach": false,
  1645  	     "Tty": false,
  1646          }
  1647  
  1648  **Example response**:
  1649  
  1650          HTTP/1.1 200 OK
  1651          Content-Type: application/vnd.docker.raw-stream
  1652  
  1653          {{ STREAM }}
  1654  
  1655  Json Parameters:
  1656  
  1657  -   **Detach** - Detach from the exec command
  1658  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1659  
  1660  Status Codes:
  1661  
  1662  -   **200** – no error
  1663  -   **404** – no such exec instance
  1664  
  1665      **Stream details**:
  1666      Similar to the stream behavior of `POST /containers/(id or name)/attach` API
  1667  
  1668  ### Exec Resize
  1669  
  1670  `POST /exec/(id)/resize`
  1671  
  1672  Resizes the tty session used by the exec command `id`.
  1673  This API is valid only if `tty` was specified as part of creating and starting the exec command.
  1674  
  1675  **Example request**:
  1676  
  1677          POST /exec/e90e34656806/resize HTTP/1.1
  1678          Content-Type: plain/text
  1679  
  1680  **Example response**:
  1681  
  1682          HTTP/1.1 201 Created
  1683          Content-Type: plain/text
  1684  
  1685  Query Parameters:
  1686  
  1687  -   **h** – height of tty session
  1688  -   **w** – width
  1689  
  1690  Status Codes:
  1691  
  1692  -   **201** – no error
  1693  -   **404** – no such exec instance
  1694  
  1695  ### Exec Inspect
  1696  
  1697  `GET /exec/(id)/json`
  1698  
  1699  Return low-level information about the exec command `id`.
  1700  
  1701  **Example request**:
  1702  
  1703          GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  1704  
  1705  **Example response**:
  1706  
  1707          HTTP/1.1 200 OK
  1708          Content-Type: plain/text
  1709  
  1710          {
  1711            "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  1712            "Running" : false,
  1713            "ExitCode" : 2,
  1714            "ProcessConfig" : {
  1715              "privileged" : false,
  1716              "user" : "",
  1717              "tty" : false,
  1718              "entrypoint" : "sh",
  1719              "arguments" : [
  1720                "-c",
  1721                "exit 2"
  1722              ]
  1723            },
  1724            "OpenStdin" : false,
  1725            "OpenStderr" : false,
  1726            "OpenStdout" : false,
  1727            "Container" : {
  1728              "State" : {
  1729                "Running" : true,
  1730                "Paused" : false,
  1731                "Restarting" : false,
  1732                "OOMKilled" : false,
  1733                "Pid" : 3650,
  1734                "ExitCode" : 0,
  1735                "Error" : "",
  1736                "StartedAt" : "2014-11-17T22:26:03.717657531Z",
  1737                "FinishedAt" : "0001-01-01T00:00:00Z"
  1738              },
  1739              "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
  1740              "Created" : "2014-11-17T22:26:03.626304998Z",
  1741              "Path" : "date",
  1742              "Args" : [],
  1743              "Config" : {
  1744                "Hostname" : "8f177a186b97",
  1745                "Domainname" : "",
  1746                "User" : "",
  1747                "Memory" : 0,
  1748                "MemorySwap" : 0,
  1749                "CpuShares" : 0,
  1750                "Cpuset" : "",
  1751                "AttachStdin" : false,
  1752                "AttachStdout" : false,
  1753                "AttachStderr" : false,
  1754                "PortSpecs" : null,
  1755                "ExposedPorts" : null,
  1756                "Tty" : false,
  1757                "OpenStdin" : false,
  1758                "StdinOnce" : false,
  1759                "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
  1760                "Cmd" : [
  1761                  "date"
  1762                ],
  1763                "Image" : "ubuntu",
  1764                "Volumes" : null,
  1765                "WorkingDir" : "",
  1766                "Entrypoint" : null,
  1767                "NetworkDisabled" : false,
  1768                "MacAddress" : "",
  1769                "OnBuild" : null,
  1770                "SecurityOpt" : null
  1771              },
  1772              "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
  1773              "NetworkSettings" : {
  1774                "IPAddress" : "172.17.0.2",
  1775                "IPPrefixLen" : 16,
  1776                "MacAddress" : "02:42:ac:11:00:02",
  1777                "Gateway" : "172.17.42.1",
  1778                "Bridge" : "docker0",
  1779                "PortMapping" : null,
  1780                "Ports" : {}
  1781              },
  1782              "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
  1783              "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
  1784              "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
  1785              "Name" : "/test",
  1786              "Driver" : "aufs",
  1787              "ExecDriver" : "native-0.2",
  1788              "MountLabel" : "",
  1789              "ProcessLabel" : "",
  1790              "AppArmorProfile" : "",
  1791              "RestartCount" : 0,
  1792              "Volumes" : {},
  1793              "VolumesRW" : {}
  1794            }
  1795          }
  1796  
  1797  Status Codes:
  1798  
  1799  -   **200** – no error
  1800  -   **404** – no such exec instance
  1801  -   **500** - server error
  1802  
  1803  # 3. Going further
  1804  
  1805  ## 3.1 Inside `docker run`
  1806  
  1807  As an example, the `docker run` command line makes the following API calls:
  1808  
  1809  - Create the container
  1810  
  1811  - If the status code is 404, it means the image doesn't exist:
  1812      - Try to pull it
  1813      - Then retry to create the container
  1814  
  1815  - Start the container
  1816  
  1817  - If you are not in detached mode:
  1818  - Attach to the container, using logs=1 (to have stdout and
  1819        stderr from the container's start) and stream=1
  1820  
  1821  - If in detached mode or only stdin is attached:
  1822  - Display the container's id
  1823  
  1824  ## 3.2 Hijacking
  1825  
  1826  In this version of the API, /attach, uses hijacking to transport stdin,
  1827  stdout and stderr on the same socket. This might change in the future.
  1828  
  1829  ## 3.3 CORS Requests
  1830  
  1831  To enable cross origin requests to the remote api add the flag
  1832  "--api-enable-cors" when running docker in daemon mode.
  1833  
  1834      $ docker -d -H="192.168.1.9:2375" --api-enable-cors