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

     1  <!--[metadata]>
     2  +++
     3  title = "Remote API"
     4  description = "API Documentation for Docker"
     5  keywords = ["API, Docker, rcli, REST,  documentation"]
     6  [menu.main]
     7  parent = "engine_remoteapi"
     8  weight=-99
     9  +++
    10  <![end-metadata]-->
    11  
    12  # Docker Remote API
    13  
    14  Docker's Remote API uses an open schema model.  In this model, unknown
    15  properties in incoming messages are ignored. Client applications need to take
    16  this behavior into account to ensure they do not break when talking to newer
    17  Docker daemons.
    18  
    19  The API tends to be REST, but for some complex commands, like attach or pull,
    20  the HTTP connection is hijacked to transport STDOUT, STDIN, and STDERR.
    21  
    22  By default the Docker daemon listens on `unix:///var/run/docker.sock` and the
    23  client must have `root` access to interact with the daemon. If a group named
    24  `docker` exists on your system, `docker` applies ownership of the socket to the
    25  group.
    26  
    27  To connect to the Docker daemon with cURL you need to use cURL 7.40 or
    28  later, as these versions have the `--unix-socket` flag available. To
    29  run `curl` against the daemon on the default socket, use the
    30  following:
    31  
    32      curl --unix-socket /var/run/docker.sock http:/containers/json
    33  
    34  If you have bound the Docker daemon to a different socket path or TCP
    35  port, you would reference that in your cURL rather than the
    36  default.
    37  
    38  The current version of the API is v1.24 which means calling `/info` is the same
    39  as calling `/v1.24/info`. To call an older version of the API use
    40  `/v1.23/info`.
    41  
    42  Use the table below to find the API version for a Docker version:
    43  
    44  Docker version  | API version                        | Changes
    45  ----------------|------------------------------------|------------------------------------------------------
    46  1.12.x          | [1.24](docker_remote_api_v1.24.md) | [API changes](docker_remote_api.md#v1-24-api-changes)
    47  1.11.x          | [1.23](docker_remote_api_v1.23.md) | [API changes](docker_remote_api.md#v1-23-api-changes)
    48  1.10.x          | [1.22](docker_remote_api_v1.22.md) | [API changes](docker_remote_api.md#v1-22-api-changes)
    49  1.9.x           | [1.21](docker_remote_api_v1.21.md) | [API changes](docker_remote_api.md#v1-21-api-changes)
    50  1.8.x           | [1.20](docker_remote_api_v1.20.md) | [API changes](docker_remote_api.md#v1-20-api-changes)
    51  1.7.x           | [1.19](docker_remote_api_v1.19.md) | [API changes](docker_remote_api.md#v1-19-api-changes)
    52  1.6.x           | [1.18](docker_remote_api_v1.18.md) | [API changes](docker_remote_api.md#v1-18-api-changes)
    53  1.5.x           | [1.17](docker_remote_api_v1.17.md) | [API changes](docker_remote_api.md#v1-17-api-changes)
    54  1.4.x           | [1.16](docker_remote_api_v1.16.md) | [API changes](docker_remote_api.md#v1-16-api-changes)
    55  1.3.x           | [1.15](docker_remote_api_v1.15.md) | [API changes](docker_remote_api.md#v1-15-api-changes)
    56  1.2.x           | [1.14](docker_remote_api_v1.14.md) | [API changes](docker_remote_api.md#v1-14-api-changes)
    57  
    58  Refer to the [GitHub repository](
    59  https://github.com/docker/docker/tree/master/docs/reference/api) for
    60  older releases.
    61  
    62  ## Authentication
    63  
    64  Since API version 1.2, the auth configuration is now handled client side, so the
    65  client has to send the `authConfig` as a `POST` in `/images/(name)/push`. The
    66  `authConfig`, set as the `X-Registry-Auth` header, is currently a Base64 encoded
    67  (JSON) string with the following structure:
    68  
    69  ```
    70  {"username": "string", "password": "string", "email": "string",
    71     "serveraddress" : "string", "auth": ""}
    72  ```
    73  
    74  Callers should leave the `auth` empty. The `serveraddress` is a domain/ip
    75  without protocol. Throughout this structure, double quotes are required.
    76  
    77  ## Using Docker Machine with the API
    78  
    79  If you are using `docker-machine`, the Docker daemon is on a host that
    80  uses an encrypted TCP socket using TLS. This means, for Docker Machine users,
    81  you need to add extra parameters to `curl` or `wget` when making test
    82  API requests, for example:
    83  
    84  ```
    85  curl --insecure \
    86       --cert $DOCKER_CERT_PATH/cert.pem \
    87       --key $DOCKER_CERT_PATH/key.pem \
    88       https://YOUR_VM_IP:2376/images/json
    89  
    90  wget --no-check-certificate --certificate=$DOCKER_CERT_PATH/cert.pem \
    91       --private-key=$DOCKER_CERT_PATH/key.pem \
    92       https://YOUR_VM_IP:2376/images/json -O - -q
    93  ```
    94  
    95  ## Docker Events
    96  
    97  The following diagram depicts the container states accessible through the API.
    98  
    99  ![States](images/event_state.png)
   100  
   101  Some container-related events are not affected by container state, so they are not included in this diagram. These events are:
   102  
   103  * **export** emitted by `docker export`
   104  * **exec_create** emitted by `docker exec`
   105  * **exec_start** emitted by `docker exec` after **exec_create**
   106  
   107  Running `docker rmi` emits an **untag** event when removing an image name.  The `rmi` command may also emit **delete** events when images are deleted by ID directly or by deleting the last tag referring to the image.
   108  
   109  > **Acknowledgment**: This diagram and the accompanying text were used with the permission of Matt Good and Gilder Labs. See Matt's original blog post [Docker Events Explained](https://gliderlabs.com/blog/2015/04/14/docker-events-explained/).
   110  
   111  ## Version history
   112  
   113  This section lists each version from latest to oldest.  Each listing includes a link to the full documentation set and the changes relevant in that release.
   114  
   115  ### v1.24 API changes
   116  
   117  [Docker Remote API v1.24](docker_remote_api_v1.24.md) documentation
   118  
   119  * `POST /containers/create` now takes `StorageOpt` field.
   120  
   121  ### v1.23 API changes
   122  
   123  [Docker Remote API v1.23](docker_remote_api_v1.23.md) documentation
   124  
   125  * `GET /containers/json` returns the state of the container, one of `created`, `restarting`, `running`, `paused`, `exited` or `dead`.
   126  * `GET /containers/json` returns the mount points for the container.
   127  * `GET /networks/(name)` now returns an `Internal` field showing whether the network is internal or not.
   128  * `GET /networks/(name)` now returns an `EnableIPv6` field showing whether the network has ipv6 enabled or not.
   129  * `POST /containers/(name)/update` now supports updating container's restart policy.
   130  * `POST /networks/create` now supports enabling ipv6 on the network by setting the `EnableIPv6` field (doing this with a label will no longer work).
   131  * `GET /info` now returns `CgroupDriver` field showing what cgroup driver the daemon is using; `cgroupfs` or `systemd`.
   132  * `GET /info` now returns `KernelMemory` field, showing if "kernel memory limit" is supported.
   133  * `POST /containers/create` now takes `PidsLimit` field, if the kernel is >= 4.3 and the pids cgroup is supported.
   134  * `GET /containers/(id or name)/stats` now returns `pids_stats`, if the kernel is >= 4.3 and the pids cgroup is supported.
   135  * `POST /containers/create` now allows you to override usernamespaces remapping and use privileged options for the container.
   136  * `POST /containers/create` now allows specifying `nocopy` for named volumes, which disables automatic copying from the container path to the volume.
   137  * `POST /auth` now returns an `IdentityToken` when supported by a registry.
   138  * `POST /containers/create` with both `Hostname` and `Domainname` fields specified will result in the container's hostname being set to `Hostname`, rather than `Hostname.Domainname`.
   139  * `GET /volumes` now supports more filters, new added filters are `name` and `driver`.
   140  
   141  ### v1.22 API changes
   142  
   143  [Docker Remote API v1.22](docker_remote_api_v1.22.md) documentation
   144  
   145  * `POST /container/(name)/update` updates the resources of a container.
   146  * `GET /containers/json` supports filter `isolation` on Windows.
   147  * `GET /containers/json` now returns the list of networks of containers.
   148  * `GET /info` Now returns `Architecture` and `OSType` fields, providing information
   149    about the host architecture and operating system type that the daemon runs on.
   150  * `GET /networks/(name)` now returns a `Name` field for each container attached to the network.
   151  * `GET /version` now returns the `BuildTime` field in RFC3339Nano format to make it
   152    consistent with other date/time values returned by the API.
   153  * `AuthConfig` now supports a `registrytoken` for token based authentication
   154  * `POST /containers/create` now has a 4M minimum value limit for `HostConfig.KernelMemory`
   155  * Pushes initiated with `POST /images/(name)/push` and pulls initiated with `POST /images/create`
   156    will be cancelled if the HTTP connection making the API request is closed before
   157    the push or pull completes.
   158  * `POST /containers/create` now allows you to set a read/write rate limit for a
   159    device (in bytes per second or IO per second).
   160  * `GET /networks` now supports filtering by `name`, `id` and `type`.
   161  * `POST /containers/create` now allows you to set the static IPv4 and/or IPv6 address for the container.
   162  * `POST /networks/(id)/connect` now allows you to set the static IPv4 and/or IPv6 address for the container.
   163  * `GET /info` now includes the number of containers running, stopped, and paused.
   164  * `POST /networks/create` now supports restricting external access to the network by setting the `Internal` field.
   165  * `POST /networks/(id)/disconnect` now includes a `Force` option to forcefully disconnect a container from network
   166  * `GET /containers/(id)/json` now returns the `NetworkID` of containers.
   167  * `POST /networks/create` Now supports an options field in the IPAM config that provides options
   168    for custom IPAM plugins.
   169  * `GET /networks/{network-id}` Now returns IPAM config options for custom IPAM plugins if any
   170    are available.
   171  * `GET /networks/<network-id>` now returns subnets info for user-defined networks.
   172  * `GET /info` can now return a `SystemStatus` field useful for returning additional information about applications
   173    that are built on top of engine.
   174  
   175  ### v1.21 API changes
   176  
   177  [Docker Remote API v1.21](docker_remote_api_v1.21.md) documentation
   178  
   179  * `POST /containers/create` and `POST /containers/(id)/start` allow you to configure kernel parameters (sysctls) for use in the container.
   180  * `GET /volumes` lists volumes from all volume drivers.
   181  * `POST /volumes/create` to create a volume.
   182  * `GET /volumes/(name)` get low-level information about a volume.
   183  * `DELETE /volumes/(name)` remove a volume with the specified name.
   184  * `VolumeDriver` was moved from `config` to `HostConfig` to make the configuration portable.
   185  * `GET /images/(name)/json` now returns information about an image's `RepoTags` and `RepoDigests`.
   186  * The `config` option now accepts the field `StopSignal`, which specifies the signal to use to kill a container.
   187  * `GET /containers/(id)/stats` will return networking information respectively for each interface.
   188  * The `HostConfig` option now includes the `DnsOptions` field to configure the container's DNS options.
   189  * `POST /build` now optionally takes a serialized map of build-time variables.
   190  * `GET /events` now includes a `timenano` field, in addition to the existing `time` field.
   191  * `GET /events` now supports filtering by image and container labels.
   192  * `GET /info` now lists engine version information and return the information of `CPUShares` and `Cpuset`.
   193  * `GET /containers/json` will return `ImageID` of the image used by container.
   194  * `POST /exec/(name)/start` will now return an HTTP 409 when the container is either stopped or paused.
   195  * `GET /containers/(name)/json` now accepts a `size` parameter. Setting this parameter to '1' returns container size information in the `SizeRw` and `SizeRootFs` fields.
   196  * `GET /containers/(name)/json` now returns a `NetworkSettings.Networks` field,
   197    detailing network settings per network. This field deprecates the
   198    `NetworkSettings.Gateway`, `NetworkSettings.IPAddress`,
   199    `NetworkSettings.IPPrefixLen`, and `NetworkSettings.MacAddress` fields, which
   200    are still returned for backward-compatibility, but will be removed in a future version.
   201  * `GET /exec/(id)/json` now returns a `NetworkSettings.Networks` field,
   202    detailing networksettings per network. This field deprecates the
   203    `NetworkSettings.Gateway`, `NetworkSettings.IPAddress`,
   204    `NetworkSettings.IPPrefixLen`, and `NetworkSettings.MacAddress` fields, which
   205    are still returned for backward-compatibility, but will be removed in a future version.
   206  * The `HostConfig` option now includes the `OomScoreAdj` field for adjusting the
   207    badness heuristic. This heuristic selects which processes the OOM killer kills
   208    under out-of-memory conditions.
   209  
   210  ### v1.20 API changes
   211  
   212  [Docker Remote API v1.20](docker_remote_api_v1.20.md) documentation
   213  
   214  * `GET /containers/(id)/archive` get an archive of filesystem content from a container.
   215  * `PUT /containers/(id)/archive` upload an archive of content to be extracted to
   216  an existing directory inside a container's filesystem.
   217  * `POST /containers/(id)/copy` is deprecated in favor of the above `archive`
   218  endpoint which can be used to download files and directories from a container.
   219  * The `hostConfig` option now accepts the field `GroupAdd`, which specifies a
   220  list of additional groups that the container process will run as.
   221  
   222  ### v1.19 API changes
   223  
   224  [Docker Remote API v1.19](docker_remote_api_v1.19.md) documentation
   225  
   226  * When the daemon detects a version mismatch with the client, usually when
   227  the client is newer than the daemon, an HTTP 400 is now returned instead
   228  of a 404.
   229  * `GET /containers/(id)/stats` now accepts `stream` bool to get only one set of stats and disconnect.
   230  * `GET /containers/(id)/logs` now accepts a `since` timestamp parameter.
   231  * `GET /info` The fields `Debug`, `IPv4Forwarding`, `MemoryLimit`, and
   232  `SwapLimit` are now returned as boolean instead of as an int. In addition, the
   233  end point now returns the new boolean fields `CpuCfsPeriod`, `CpuCfsQuota`, and
   234  `OomKillDisable`.
   235  * The `hostConfig` option now accepts the fields `CpuPeriod` and `CpuQuota`
   236  * `POST /build` accepts `cpuperiod` and `cpuquota` options
   237  
   238  ### v1.18 API changes
   239  
   240  [Docker Remote API v1.18](docker_remote_api_v1.18.md) documentation
   241  
   242  * `GET /version` now returns `Os`, `Arch` and `KernelVersion`.
   243  * `POST /containers/create` and `POST /containers/(id)/start`allow you to  set ulimit settings for use in the container.
   244  * `GET /info` now returns `SystemTime`, `HttpProxy`,`HttpsProxy` and `NoProxy`.
   245  * `GET /images/json` added a `RepoDigests` field to include image digest information.
   246  * `POST /build` can now set resource constraints for all containers created for the build.
   247  * `CgroupParent` can be passed in the host config to setup container cgroups under a specific cgroup.
   248  * `POST /build` closing the HTTP request cancels the build
   249  * `POST /containers/(id)/exec` includes `Warnings` field to response.
   250  
   251  ### v1.17 API changes
   252  
   253  [Docker Remote API v1.17](docker_remote_api_v1.17.md) documentation
   254  
   255  * The build supports `LABEL` command. Use this to add metadata to an image. For
   256  example you could add data describing the content of an image. `LABEL
   257  "com.example.vendor"="ACME Incorporated"`
   258  * `POST /containers/(id)/attach` and `POST /exec/(id)/start`
   259  * The Docker client now hints potential proxies about connection hijacking using HTTP Upgrade headers.
   260  * `POST /containers/create` sets labels on container create describing the container.
   261  * `GET /containers/json` returns the labels associated with the containers (`Labels`).
   262  * `GET /containers/(id)/json` returns the list current execs associated with the
   263  container (`ExecIDs`). This endpoint now returns the container labels
   264  (`Config.Labels`).
   265  * `POST /containers/(id)/rename` renames a container `id` to a new name.*
   266  * `POST /containers/create` and `POST /containers/(id)/start` callers can pass
   267  `ReadonlyRootfs` in the host config to mount the container's root filesystem as
   268  read only.
   269  * `GET /containers/(id)/stats` returns a live stream of a container's resource usage statistics.
   270  * `GET /images/json` returns the labels associated with each image (`Labels`).
   271  
   272  
   273  ### v1.16 API changes
   274  
   275  [Docker Remote API v1.16](docker_remote_api_v1.16.md)
   276  
   277  * `GET /info` returns the number of CPUs available on the machine (`NCPU`),
   278  total memory available (`MemTotal`), a user-friendly name describing the running Docker daemon (`Name`), a unique ID identifying the daemon (`ID`), and
   279  a list of daemon labels (`Labels`).
   280  * `POST /containers/create` callers can set the new container's MAC address explicitly.
   281  * Volumes are now initialized when the container is created.
   282  * `POST /containers/(id)/copy` copies data which is contained in a volume.
   283  
   284  ### v1.15 API changes
   285  
   286  [Docker Remote API v1.15](docker_remote_api_v1.15.md) documentation
   287  
   288  `POST /containers/create` you can set a container's `HostConfig` when creating a
   289  container. Previously this was only available when starting a container.
   290  
   291  ### v1.14 API changes
   292  
   293  [Docker Remote API v1.14](docker_remote_api_v1.14.md) documentation
   294  
   295  * `DELETE /containers/(id)` when using `force`, the container will be immediately killed with SIGKILL.
   296  * `POST /containers/(id)/start` the `HostConfig` option accepts the field `CapAdd`, which specifies a list of capabilities
   297  to add, and the field `CapDrop`, which specifies a list of capabilities to drop.
   298  * `POST /images/create` th `fromImage` and `repo` parameters support the
   299  `repo:tag` format. Consequently,  the `tag` parameter is now obsolete. Using the
   300  new format and the `tag` parameter at the same time will return an error.