From a4f6920731c6af27a7e89c3da8d0e6fd309de90a Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Tue, 12 Jan 2016 08:33:41 +0100 Subject: [PATCH] Add a specific config for the update command This allows to define clearly what is mutable or not in a container and remove the use of the internal HostConfig struct to be used. Signed-off-by: Vincent Demeester --- api/server/router/container/container_routes.go | 11 +++++++++-- docs/reference/api/docker_remote_api.md | 3 ++- docs/reference/api/docker_remote_api_v1.22.md | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/api/server/router/container/container_routes.go b/api/server/router/container/container_routes.go index ee2f1ef2f8..4e2ffca29b 100644 --- a/api/server/router/container/container_routes.go +++ b/api/server/router/container/container_routes.go @@ -1,6 +1,7 @@ package container import ( + "encoding/json" "fmt" "io" "net/http" @@ -332,11 +333,17 @@ func (s *containerRouter) postContainerUpdate(ctx context.Context, w http.Respon return err } - _, hostConfig, _, err := runconfig.DecodeContainerConfig(r.Body) - if err != nil { + var updateConfig container.UpdateConfig + + decoder := json.NewDecoder(r.Body) + if err := decoder.Decode(&updateConfig); err != nil { return err } + hostConfig := &container.HostConfig{ + Resources: updateConfig.Resources, + } + name := vars["name"] warnings, err := s.backend.ContainerUpdate(name, hostConfig) if err != nil { diff --git a/docs/reference/api/docker_remote_api.md b/docs/reference/api/docker_remote_api.md index 028c41e362..6909928ccb 100644 --- a/docs/reference/api/docker_remote_api.md +++ b/docs/reference/api/docker_remote_api.md @@ -95,6 +95,7 @@ This section lists each version from latest to oldest. Each listing includes a [Docker Remote API v1.22](docker_remote_api_v1.22.md) documentation +* `POST /container/(name)/update` updates the resources of a container. * `GET /containers/json` supports filter `isolation` on Windows. * `GET /containers/json` now returns the list of networks of containers. * `GET /info` Now returns `Architecture` and `OSType` fields, providing information @@ -120,7 +121,7 @@ This section lists each version from latest to oldest. Each listing includes a * `GET /volumes` lists volumes from all volume drivers. * `POST /volumes/create` to create a volume. * `GET /volumes/(name)` get low-level information about a volume. -* `DELETE /volumes/(name)`remove a volume with the specified name. +* `DELETE /volumes/(name)` remove a volume with the specified name. * `VolumeDriver` was moved from `config` to `HostConfig` to make the configuration portable. * `GET /images/(name)/json` now returns information about an image's `RepoTags` and `RepoDigests`. * The `config` option now accepts the field `StopSignal`, which specifies the signal to use to kill a container. diff --git a/docs/reference/api/docker_remote_api_v1.22.md b/docs/reference/api/docker_remote_api_v1.22.md index 9483dd4eb4..badb0b8c1f 100644 --- a/docs/reference/api/docker_remote_api_v1.22.md +++ b/docs/reference/api/docker_remote_api_v1.22.md @@ -1023,7 +1023,7 @@ Update resource configs of one or more containers. Content-Type: application/json { - "HostConfig": { + "UpdateConfig": { "Resources": { "BlkioWeight": 300, "CpuShares": 512,