diff --git a/CHANGELOG.md b/CHANGELOG.md index b65ab4023e2b8f97fba42de86f9207a8328210a5..aca0eec1896d6498dd3721c9ad279370fdc0627f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,7 +99,6 @@ be found. + Add `Isolation` to the /info endpoint [#26255](https://github.com/docker/docker/pull/26255) + Add `userns` to the /info endpoint [#27840](https://github.com/docker/docker/pull/27840) - Do not allow more than one mode be requested at once in the services endpoint [#26643](https://github.com/docker/docker/pull/26643) -+ Add `--mount` flag to `docker create` and `docker run` [#26825](https://github.com/docker/docker/pull/26825)[#28150](https://github.com/docker/docker/pull/28150) + Add capability to /containers/create API to specify mounts in a more granular and safer way [#22373](https://github.com/docker/docker/pull/22373) + Add `--format` flag to `network ls` and `volume ls` [#23475](https://github.com/docker/docker/pull/23475) * Allow the top-level `docker inspect` command to inspect any kind of resource [#23614](https://github.com/docker/docker/pull/23614) diff --git a/Dockerfile.ppc64le b/Dockerfile.ppc64le index 3f550d1804cb46b620f1ce956bf74337ee5e0bd8..bf1e539d1a3966a9043c0e0295a680b817d5553c 100644 --- a/Dockerfile.ppc64le +++ b/Dockerfile.ppc64le @@ -18,6 +18,10 @@ # ppc64le/golang is a debian:jessie based image with golang installed FROM ppc64le/golang:1.6.3 +# allow replacing httpredir or deb mirror +ARG APT_MIRROR=deb.debian.org +RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list + # Packaged dependencies RUN apt-get update && apt-get install -y \ apparmor \ diff --git a/Makefile b/Makefile index 31d1fa44ccec4714a55f17104bb874273cad897d..81bde6b4f6ec9c8b05cd7505b2d572ae0d282762 100644 --- a/Makefile +++ b/Makefile @@ -144,4 +144,4 @@ swagger-gen: -w /go/src/github.com/docker/docker \ --entrypoint hack/generate-swagger-api.sh \ -e GOPATH=/go \ - quay.io/goswagger/swagger + quay.io/goswagger/swagger:0.7.4 diff --git a/api/server/router/swarm/cluster_routes.go b/api/server/router/swarm/cluster_routes.go index cb4ae3a7b39294a3be7464e223a0f94595aee56c..fe976434bca66521e4ce185fe794c873ed2125db 100644 --- a/api/server/router/swarm/cluster_routes.go +++ b/api/server/router/swarm/cluster_routes.go @@ -383,6 +383,7 @@ func (sr *swarmRouter) removeSecret(ctx context.Context, w http.ResponseWriter, if err := sr.backend.RemoveSecret(vars["id"]); err != nil { return err } + w.WriteHeader(http.StatusNoContent) return nil } diff --git a/api/swagger.yaml b/api/swagger.yaml index d5e55718b1a2ec2044c512b9344d6c75c96970c8..f3f0f4b66e7bdb62f52f4a86a5741dcb5adbb4cb 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -1,3 +1,14 @@ +# A Swagger 2.0 (a.k.a. OpenAPI) definition of the Engine API. +# +# This is used for generating API documentation and the types used by the +# client/server. See api/README.md for more information. +# +# Some style notes: +# - This file is used by ReDoc, which allows GitHub Flavored Markdown in +# descriptions. +# - There is no maximum line length, for ease of editing and pretty diffs. +# - operationIds are in the format "NounVerb", with a singular noun. + swagger: "2.0" schemes: - "http" @@ -45,13 +56,13 @@ info: Docker version | API version | Changes ----------------|-------------|--------- - 1.12.x | [1.24](/engine/api/v1.24/) | [API changes](/engine/api/version-history/#v1-24-api-changes) - 1.11.x | [1.23](/engine/api/v1.23/) | [API changes](/engine/api/version-history/#v1-23-api-changes) - 1.10.x | [1.22](/engine/api/v1.22/) | [API changes](/engine/api/version-history/#v1-22-api-changes) - 1.9.x | [1.21](/engine/api/v1.21/) | [API changes](/engine/api/version-history/#v1-21-api-changes) - 1.8.x | [1.20](/engine/api/v1.20/) | [API changes](/engine/api/version-history/#v1-20-api-changes) - 1.7.x | [1.19](/engine/api/v1.19/) | [API changes](/engine/api/version-history/#v1-19-api-changes) - 1.6.x | [1.18](/engine/api/v1.18/) | [API changes](/engine/api/version-history/#v1-18-api-changes) + 1.12.x | [1.24](https://docs.docker.com/engine/api/v1.24/) | [API changes](https://docs.docker.com/engine/api/version-history/#v1-24-api-changes) + 1.11.x | [1.23](https://docs.docker.com/engine/api/v1.23/) | [API changes](https://docs.docker.com/engine/api/version-history/#v1-23-api-changes) + 1.10.x | [1.22](https://docs.docker.com/engine/api/v1.22/) | [API changes](https://docs.docker.com/engine/api/version-history/#v1-22-api-changes) + 1.9.x | [1.21](https://docs.docker.com/engine/api/v1.21/) | [API changes](https://docs.docker.com/engine/api/version-history/#v1-21-api-changes) + 1.8.x | [1.20](https://docs.docker.com/engine/api/v1.20/) | [API changes](https://docs.docker.com/engine/api/version-history/#v1-20-api-changes) + 1.7.x | [1.19](https://docs.docker.com/engine/api/v1.19/) | [API changes](https://docs.docker.com/engine/api/version-history/#v1-19-api-changes) + 1.6.x | [1.18](https://docs.docker.com/engine/api/v1.18/) | [API changes](https://docs.docker.com/engine/api/version-history/#v1-18-api-changes) # Authentication @@ -68,7 +79,7 @@ info: The `serveraddress` is a domain/IP without a protocol. Throughout this structure, double quotes are required. - If you have already got an identity token from the [`/auth` endpoint](#operation/checkAuthentication), you can just pass this instead of credentials: + If you have already got an identity token from the [`/auth` endpoint](#operation/SystemAuth), you can just pass this instead of credentials: ``` { @@ -76,6 +87,48 @@ info: } ``` +# The tags on paths define the menu sections in the ReDoc documentation, so +# the usage of tags must make sense for that: +# - They should be singular, not plural. +# - There should not be too many tags, or the menu becomes unwieldly. For +# example, it is preferable to add a path to the "System" tag instead of +# creating a tag with a single path in it. +# - The order of tags in this list defines the order in the menu. +tags: + # Primary objects + - name: "Container" + description: | + Create and manage containers. + - name: "Image" + - name: "Network" + description: | + Networks are user-defined networks that containers can be attached to. See the [networking documentation](https://docs.docker.com/engine/userguide/networking/) for more information. + - name: "Volume" + description: | + Create and manage persistent storage that can be attached to containers. + - name: "Exec" + description: | + Run new commands inside running containers. See the [command-line reference](https://docs.docker.com/engine/reference/commandline/exec/) for more information. + + To exec a command in a container, you first need to create an exec instance, then start it. These two API endpoints are wrapped up in a single command-line command, `docker exec`. + - name: "Secret" + # Swarm things + - name: "Swarm" + description: | + Engines can be clustered together in a swarm. See [the swarm mode documentation](https://docs.docker.com/engine/swarm/) for more information. + - name: "Node" + description: | + Nodes are instances of the Engine participating in a swarm. Swarm mode must be enabled for these endpoints to work. + - name: "Service" + description: | + Services are the definitions of tasks to run on a swarm. Swarm mode must be enabled for these endpoints to work. + - name: "Task" + description: | + A task is a container running on a swarm. It is the atomic scheduling unit of swarm. Swarm mode must be enabled for these endpoints to work. + # System things + - name: "Plugin" + - name: "System" + definitions: Port: type: "object" @@ -2387,7 +2440,7 @@ paths: /containers/json: get: summary: "List containers" - operationId: "GetContainerList" + operationId: "ContainerList" produces: - "application/json" parameters: @@ -2565,8 +2618,7 @@ paths: description: "server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Container" + tags: ["Container"] /containers/create: post: summary: "Create a container" @@ -2765,13 +2817,12 @@ paths: description: "server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Container" + tags: ["Container"] /containers/{id}/json: get: summary: "Inspect a container" description: "Return low-level information about a container." - operationId: "GetContainerInspect" + operationId: "ContainerInspect" produces: - "application/json" responses: @@ -3042,13 +3093,12 @@ paths: type: "boolean" default: false description: "Return the size of container as fields `SizeRw` and `SizeRootFs`" - tags: - - "Container" + tags: ["Container"] /containers/{id}/top: get: summary: "List processes running inside a container" description: "On Unix systems, this is done by running the `ps` command. This endpoint is not supported on Windows." - operationId: "GetContainerTop" + operationId: "ContainerTop" responses: 200: description: "no error" @@ -3119,8 +3169,7 @@ paths: description: "The arguments to pass to `ps`. For example, `aux`" type: "string" default: "-ef" - tags: - - "Container" + tags: ["Container"] /containers/{id}/logs: get: summary: "Get container logs" @@ -3128,7 +3177,7 @@ paths: Get `stdout` and `stderr` logs from a container. Note: This endpoint works only for containers with the `json-file` or `journald` logging driver. - operationId: "GetContainerLogs" + operationId: "ContainerLogs" responses: 101: description: "logs returned as a stream" @@ -3161,7 +3210,7 @@ paths: description: | Return the logs as a stream. - This will return a `101` HTTP response with a `Connection: upgrade` header, then hijack the HTTP connection to send raw output. For more information about hijacking and the stream format, [see the documentation for the attach endpoint](#operation/PostContainerAttach). + This will return a `101` HTTP response with a `Connection: upgrade` header, then hijack the HTTP connection to send raw output. For more information about hijacking and the stream format, [see the documentation for the attach endpoint](#operation/ContainerAttach). type: "boolean" default: false - name: "stdout" @@ -3189,8 +3238,7 @@ paths: description: "Only return this number of log lines from the end of the logs. Specify as an integer or `all` to output all log lines." type: "string" default: "all" - tags: - - "Container" + tags: ["Container"] /containers/{id}/changes: get: summary: "Get changes on a container’s filesystem" @@ -3200,7 +3248,7 @@ paths: - `0`: Modified - `1`: Added - `2`: Deleted - operationId: "GetContainerChanges" + operationId: "ContainerChanges" produces: - "application/json" responses: @@ -3246,13 +3294,12 @@ paths: required: true description: "ID or name of the container" type: "string" - tags: - - "Container" + tags: ["Container"] /containers/{id}/export: get: summary: "Export a container" description: "Export the contents of a container as a tarball." - operationId: "GetContainerExport" + operationId: "ContainerExport" produces: - "application/octet-stream" responses: @@ -3275,8 +3322,7 @@ paths: required: true description: "ID or name of the container" type: "string" - tags: - - "Container" + tags: ["Container"] /containers/{id}/stats: get: summary: "Get container stats based on resource usage" @@ -3284,7 +3330,7 @@ paths: This endpoint returns a live stream of a container’s resource usage statistics. The `precpu_stats` is the CPU statistic of last read, which is used for calculating the CPU usage percentage. It is not the same as the `cpu_stats` field. - operationId: "GetContainerStats" + operationId: "ContainerStats" produces: - "application/json" responses: @@ -3404,13 +3450,12 @@ paths: description: "Stream the output. If false, the stats will be output once and then it will disconnect." type: "boolean" default: true - tags: - - "Container" + tags: ["Container"] /containers/{id}/resize: post: summary: "Resize a container TTY" description: "Resize the TTY for a container. You must restart the container for the resize to take effect." - operationId: "PostContainerResize" + operationId: "ContainerResize" consumes: - "application/octet-stream" produces: @@ -3443,12 +3488,11 @@ paths: in: "query" description: "Width of the tty session in characters" type: "integer" - tags: - - "Container" + tags: ["Container"] /containers/{id}/start: post: summary: "Start a container" - operationId: "PostContainerStart" + operationId: "ContainerStart" responses: 204: description: "no error" @@ -3477,12 +3521,11 @@ paths: in: "query" description: "Override the key sequence for detaching a container. Format is a single character `[a-Z]` or `ctrl-` where `` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`." type: "string" - tags: - - "Container" + tags: ["Container"] /containers/{id}/stop: post: summary: "Stop a container" - operationId: "PostContainerStop" + operationId: "ContainerStop" responses: 204: description: "no error" @@ -3511,12 +3554,11 @@ paths: in: "query" description: "Number of seconds to wait before killing the container" type: "integer" - tags: - - "Container" + tags: ["Container"] /containers/{id}/restart: post: summary: "Restart a container" - operationId: "PostContainerRestart" + operationId: "ContainerRestart" responses: 204: description: "no error" @@ -3541,13 +3583,12 @@ paths: in: "query" description: "Number of seconds to wait before killing the container" type: "integer" - tags: - - "Container" + tags: ["Container"] /containers/{id}/kill: post: summary: "Kill a container" description: "Send a POSIX signal to a container, defaulting to killing to the container." - operationId: "PostContainerKill" + operationId: "ContainerKill" responses: 204: description: "no error" @@ -3573,8 +3614,7 @@ paths: description: "Signal to send to the container as an integer or string (e.g. `SIGINT`)" type: "string" default: "SIGKILL" - tags: - - "Container" + tags: ["Container"] /containers/{id}/update: post: summary: "Update a container" @@ -3635,12 +3675,11 @@ paths: RestartPolicy: MaximumRetryCount: 4 Name: "on-failure" - tags: - - "Container" + tags: ["Container"] /containers/{id}/rename: post: summary: "Rename a container" - operationId: "PostContainerRename" + operationId: "ContainerRename" responses: 204: description: "no error" @@ -3670,8 +3709,7 @@ paths: required: true description: "New name for the container" type: "string" - tags: - - "Container" + tags: ["Container"] /containers/{id}/pause: post: summary: "Pause a container" @@ -3679,7 +3717,7 @@ paths: Use the cgroups freezer to suspend all processes in a container. Traditionally, when suspending a process the `SIGSTOP` signal is used, which is observable by the process being suspended. With the cgroups freezer the process is unaware, and unable to capture, that it is being suspended, and subsequently resumed. - operationId: "PostContainerPause" + operationId: "ContainerPause" responses: 204: description: "no error" @@ -3700,13 +3738,12 @@ paths: required: true description: "ID or name of the container" type: "string" - tags: - - "Container" + tags: ["Container"] /containers/{id}/unpause: post: summary: "Unpause a container" description: "Resume a container which has been paused." - operationId: "PostContainerUnpause" + operationId: "ContainerUnpause" responses: 204: description: "no error" @@ -3727,8 +3764,7 @@ paths: required: true description: "ID or name of the container" type: "string" - tags: - - "Container" + tags: ["Container"] /containers/{id}/attach: post: summary: "Attach to a container" @@ -3737,7 +3773,7 @@ paths: Either the `stream` or `logs` parameter must be `true` for this endpoint to do anything. - See [the documentation for the `docker attach` command](/engine/reference/commandline/attach/) for more details. + See [the documentation for the `docker attach` command](https://docs.docker.com/engine/reference/commandline/attach/) for more details. ### Hijacking @@ -3777,7 +3813,7 @@ paths: ### Stream format - When the TTY setting is disabled in [`POST /containers/create`](#operation/PostContainerCreate), the stream over the hijacked connected is multiplexed to separate out `stdout` and `stderr`. The stream consists of a series of frames, each containing a header and a payload. + When the TTY setting is disabled in [`POST /containers/create`](#operation/ContainerCreate), the stream over the hijacked connected is multiplexed to separate out `stdout` and `stderr`. The stream consists of a series of frames, each containing a header and a payload. The header contains the information which the stream writes (`stdout` or `stderr`). It also contains the size of the associated frame encoded in the last four bytes (`uint32`). @@ -3807,9 +3843,9 @@ paths: ### Stream format when using a TTY - When the TTY setting is enabled in [`POST /containers/create`](#operation/PostContainerCreate), the stream is not multiplexed. The data exchanged over the hijacked connection is simply the raw data from the process PTY and client's `stdin`. + When the TTY setting is enabled in [`POST /containers/create`](#operation/ContainerCreate), the stream is not multiplexed. The data exchanged over the hijacked connection is simply the raw data from the process PTY and client's `stdin`. - operationId: "PostContainerAttach" + operationId: "ContainerAttach" produces: - "application/vnd.docker.raw-stream" responses: @@ -3872,12 +3908,11 @@ paths: description: "Attach to `stderr`" type: "boolean" default: false - tags: - - "Container" + tags: ["Container"] /containers/{id}/attach/ws: get: summary: "Attach to a container via a websocket" - operationId: "PostContainerAttachWebsocket" + operationId: "ContainerAttachWebsocket" responses: 101: description: "no error, hints proxy about hijacking" @@ -3933,8 +3968,7 @@ paths: description: "Attach to `stderr`" type: "boolean" default: false - tags: - - "Container" + tags: ["Container"] /containers/{id}/wait: post: summary: "Wait for a container" @@ -3969,12 +4003,11 @@ paths: required: true description: "ID or name of the container" type: "string" - tags: - - "Container" + tags: ["Container"] /containers/{id}: delete: summary: "Remove a container" - operationId: "DeleteContainer" + operationId: "ContainerDelete" responses: 204: description: "no error" @@ -4009,13 +4042,12 @@ paths: description: "If the container is running, kill it before removing it." type: "boolean" default: false - tags: - - "Container" + tags: ["Container"] /containers/{id}/archive: head: summary: "Get information about files in a container" description: "A response header `X-Docker-Container-Path-Stat` is return containing a base64 - encoded JSON object with some filesystem header information about the path." - operationId: "HeadContainerArchive" + operationId: "ContainerArchiveHead" responses: 200: description: "no error" @@ -4056,12 +4088,11 @@ paths: required: true description: "Resource in the container’s filesystem to archive." type: "string" - tags: - - "Container" + tags: ["Container"] get: summary: "Get an archive of a filesystem resource in a container" description: "Get an tar archive of a resource in the filesystem of container id." - operationId: "GetContainerArchive" + operationId: "ContainerGetArchive" produces: - "application/x-tar" responses: @@ -4100,12 +4131,11 @@ paths: required: true description: "Resource in the container’s filesystem to archive." type: "string" - tags: - - "Container" + tags: ["Container"] put: summary: "Extract an archive of files or folders to a directory in a container" description: "Upload a tar archive to be extracted to a path in the filesystem of container id." - operationId: "PutContainerArchive" + operationId: "ContainerPutArchive" consumes: - "application/x-tar" - "application/octet-stream" @@ -4152,8 +4182,7 @@ paths: description: "The input stream must be a tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz." schema: type: "string" - tags: - - "Container" + tags: ["Container"] /containers/prune: post: summary: "Delete stopped containers" @@ -4181,13 +4210,12 @@ paths: description: "Server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Container" + tags: ["Container"] /images/json: get: summary: "List Images" description: "Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image." - operationId: "GetImageList" + operationId: "ImageList" produces: - "application/json" responses: @@ -4253,20 +4281,19 @@ paths: description: "Show digest information as a `RepoDigests` field on each image." type: "boolean" default: false - tags: - - "Image" + tags: ["Image"] /build: post: summary: "Build an image" description: | Build an image from a tar archive with a `Dockerfile` in it. - The `Dockerfile` specifies how the image is built from the tar archive. It is typically in the archive's root, but can be at a different path or have a different name by specifying the `dockerfile` parameter. [See the `Dockerfile` reference for more information](/engine/reference/builder/). + The `Dockerfile` specifies how the image is built from the tar archive. It is typically in the archive's root, but can be at a different path or have a different name by specifying the `dockerfile` parameter. [See the `Dockerfile` reference for more information](https://docs.docker.com/engine/reference/builder/). The Docker daemon performs a preliminary validation of the `Dockerfile` before starting the build, and returns an error if the syntax is incorrect. After that, each instruction is run one-by-one until the ID of the new image is output. The build is canceled if the client drops the connection by quitting or being killed. - operationId: "PostImageBuild" + operationId: "ImageBuild" consumes: - "application/octet-stream" produces: @@ -4345,7 +4372,7 @@ paths: type: "integer" - name: "buildargs" in: "query" - description: "JSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the buildargs as the environment context for commands run via the `Dockerfile` RUN instruction, or for variable expansion in other `Dockerfile` instructions. This is not meant for passing secret values. [Read more about the buildargs instruction.](/engine/reference/builder/#arg)" + description: "JSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the buildargs as the environment context for commands run via the `Dockerfile` RUN instruction, or for variable expansion in other `Dockerfile` instructions. This is not meant for passing secret values. [Read more about the buildargs instruction.](https://docs.docker.com/engine/reference/builder/#arg)" type: "integer" - name: "shmsize" in: "query" @@ -4401,13 +4428,12 @@ paths: description: "server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Image" + tags: ["Image"] /images/create: post: summary: "Create an image" description: "Create an image by either pulling it from a registry or importing it." - operationId: "PostImageCreate" + operationId: "ImageCreate" consumes: - "text/plain" - "application/octet-stream" @@ -4447,13 +4473,12 @@ paths: in: "header" description: "A base64-encoded auth configuration. [See the authentication section for details.](#section/Authentication)" type: "string" - tags: - - "Image" + tags: ["Image"] /images/{name}/json: get: summary: "Inspect an image" description: "Return low-level information about an image." - operationId: "GetImageInspect" + operationId: "ImageInspect" produces: - "application/json" responses: @@ -4554,13 +4579,12 @@ paths: description: "Image name or id" type: "string" required: true - tags: - - "Image" + tags: ["Image"] /images/{name}/history: get: summary: "Get the history of an image" description: "Return parent layers of an image." - operationId: "GetImageHistory" + operationId: "ImageHistory" produces: - "application/json" responses: @@ -4625,8 +4649,7 @@ paths: description: "Image name or ID" type: "string" required: true - tags: - - "Image" + tags: ["Image"] /images/{name}/push: post: summary: "Push an image" @@ -4636,7 +4659,7 @@ paths: If you wish to push an image on to a private registry, that image must already have a tag which references the registry. For example, `registry.example.com/myimage:latest`. The push is cancelled if the HTTP connection is closed. - operationId: "PostImagePush" + operationId: "ImagePush" consumes: - "application/octet-stream" responses: @@ -4665,13 +4688,12 @@ paths: description: "A base64-encoded auth configuration. [See the authentication section for details.](#section/Authentication)" type: "string" required: true - tags: - - "Image" + tags: ["Image"] /images/{name}/tag: post: summary: "Tag an image" description: "Tag an image so that it becomes part of a repository." - operationId: "PostImageTag" + operationId: "ImageTag" responses: 201: description: "No error" @@ -4705,8 +4727,7 @@ paths: in: "query" description: "The name of the new tag." type: "string" - tags: - - "Image" + tags: ["Image"] /images/{name}: delete: summary: "Remove an image" @@ -4714,7 +4735,7 @@ paths: Remove an image, along with any untagged parent images that were referenced by that image. Images can't be removed if they have descendant images, are being used by a running container or are being used by a build. - operationId: "DeleteImage" + operationId: "ImageDelete" produces: - "application/json" responses: @@ -4757,13 +4778,12 @@ paths: description: "Do not delete untagged parent images" type: "boolean" default: false - tags: - - "Image" + tags: ["Image"] /images/search: get: summary: "Search images" description: "Search for an image on Docker Hub." - operationId: "GetImageSearch" + operationId: "ImageSearch" produces: - "application/json" responses: @@ -4824,8 +4844,7 @@ paths: - `is-automated=(true|false)` - `is-official=(true|false)` type: "string" - tags: - - "Image" + tags: ["Image"] /images/prune: post: summary: "Delete unused images" @@ -4863,13 +4882,12 @@ paths: description: "Server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Image" + tags: ["Image"] /auth: post: summary: "Check auth configuration" description: "Validate credentials for a registry and, if available, get an identity token for accessing the registry without password." - operationId: "Authenticate" + operationId: "SystemAuth" consumes: ["application/json"] produces: ["application/json"] responses: @@ -4903,11 +4921,11 @@ paths: description: "Authentication to check" schema: $ref: "#/definitions/AuthConfig" - tags: ["Registry"] + tags: ["System"] /info: get: summary: "Get system information" - operationId: "getSystemInformation" + operationId: "SystemInfo" produces: - "application/json" responses: @@ -5115,13 +5133,12 @@ paths: description: "Server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Misc" + tags: ["System"] /version: get: summary: "Get version" description: "Returns the version of Docker that is running and various information about the system that Docker is running on." - operationId: "getVersion" + operationId: "SystemVersion" produces: - "application/json" responses: @@ -5166,13 +5183,12 @@ paths: description: "server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Misc" + tags: ["System"] /_ping: get: summary: "Ping" description: "This is a dummy endpoint you can use to test if the server is accessible." - operationId: "ping" + operationId: "SystemPing" produces: - "text/plain" responses: @@ -5185,12 +5201,11 @@ paths: description: "server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Misc" + tags: ["System"] /commit: post: summary: "Create a new image from a container" - operationId: "PostImageCommit" + operationId: "ImageCommit" consumes: - "application/json" produces: @@ -5246,8 +5261,7 @@ paths: in: "query" description: "`Dockerfile` instructions to apply while committing" type: "string" - tags: - - "Image" + tags: ["Image"] /events: get: summary: "Monitor events" @@ -5266,7 +5280,7 @@ paths: The Docker daemon reports these events: `reload` - operationId: "getEvents" + operationId: "SystemEvents" produces: - "application/json" responses: @@ -5337,11 +5351,11 @@ paths: - `network=` network name or ID - `daemon=` daemon name or ID type: "string" - tags: - - "Misc" + tags: ["System"] /system/df: get: summary: "Get data usage information" + operationId: "SystemDataUsage" responses: 200: description: "no error" @@ -5426,8 +5440,7 @@ paths: description: "server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Misc" + tags: ["System"] /images/{name}/get: get: summary: "Export an image" @@ -5455,7 +5468,7 @@ paths: } } ``` - operationId: "GetImage" + operationId: "ImageGet" produces: - "application/x-tar" responses: @@ -5474,8 +5487,7 @@ paths: description: "Image name or ID" type: "string" required: true - tags: - - "Image" + tags: ["Image"] /images/get: get: summary: "Export several images" @@ -5484,8 +5496,8 @@ paths: For each value of the `names` parameter: if it is a specific name and tag (e.g. `ubuntu:latest`), then only that image (and its parents) are returned; if it is an image ID, similarly only that image (and its parents) are returned and there would be no names referenced in the 'repositories' file for this image ID. - For details on the format, see [the export image endpoint](#operation/GetImage). - operationId: "GetImageSaveAll" + For details on the format, see [the export image endpoint](#operation/ImageGet). + operationId: "ImageGetAll" produces: - "application/x-tar" responses: @@ -5505,16 +5517,15 @@ paths: type: "array" items: type: "string" - tags: - - "Image" + tags: ["Image"] /images/load: post: summary: "Import images" description: | Load a set of images and tags into a repository. - For details on the format, see [the export image endpoint](#operation/GetImage). - operationId: "PostImageLoad" + For details on the format, see [the export image endpoint](#operation/ImageGet). + operationId: "ImageLoad" consumes: - "application/x-tar" produces: @@ -5538,13 +5549,12 @@ paths: description: "Suppress progress details during load." type: "boolean" default: false - tags: - - "Image" + tags: ["Image"] /containers/{id}/exec: post: summary: "Create an exec instance" description: "Run a command inside a running container." - operationId: "PostContainerExec" + operationId: "ContainerExec" consumes: - "application/json" produces: @@ -5625,13 +5635,12 @@ paths: description: "ID or name of container" type: "string" required: true - tags: - - "Exec" + tags: ["Exec"] /exec/{id}/start: post: summary: "Start an exec instance" description: "Starts a previously set up exec instance. If detach is true, this endpoint returns immediately after starting the command. Otherwise, it sets up an interactive session with the command." - operationId: "PostExecStart" + operationId: "ExecStart" consumes: - "application/json" produces: @@ -5667,13 +5676,12 @@ paths: description: "Exec instance ID" required: true type: "string" - tags: - - "Exec" + tags: ["Exec"] /exec/{id}/resize: post: summary: "Resize an exec instance" description: "Resize the TTY session used by an exec instance. This endpoint only works if `tty` was specified as part of creating and starting the exec instance." - operationId: "PostExecResize" + operationId: "ExecResize" responses: 201: description: "No error" @@ -5695,13 +5703,12 @@ paths: in: "query" description: "Width of the TTY session in characters" type: "integer" - tags: - - "Exec" + tags: ["Exec"] /exec/{id}/json: get: summary: "Inspect an exec instance" description: "Return low-level information about an exec instance." - operationId: "PostExecInspect" + operationId: "ExecInspect" produces: - "application/json" responses: @@ -5763,13 +5770,12 @@ paths: description: "Exec instance ID" required: true type: "string" - tags: - - "Exec" + tags: ["Exec"] /volumes: get: summary: "List volumes" - operationId: "VolumesList" + operationId: "VolumeList" produces: ["application/json"] responses: 200: @@ -5831,7 +5837,7 @@ paths: /volumes/create: post: summary: "Create a volume" - operationId: "VolumesCreate" + operationId: "VolumeCreate" consumes: ["application/json"] produces: ["application/json"] responses: @@ -5881,7 +5887,7 @@ paths: /volumes/{name}: get: summary: "Inspect a volume" - operationId: "VolumesInspect" + operationId: "VolumeInspect" produces: ["application/json"] responses: 200: @@ -5907,7 +5913,7 @@ paths: delete: summary: "Remove a volume" description: "Instruct the driver to remove the volume." - operationId: "VolumesDelete" + operationId: "VolumeDelete" responses: 204: description: "The volume was removed" @@ -5962,12 +5968,11 @@ paths: description: "Server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Volume" + tags: ["Volume"] /networks: get: summary: "List networks" - operationId: "NetworksList" + operationId: "NetworkList" produces: - "application/json" responses: @@ -6049,7 +6054,7 @@ paths: /networks/{id}: get: summary: "Inspect a network" - operationId: "NetworksInspect" + operationId: "NetworkInspect" produces: - "application/json" responses: @@ -6071,7 +6076,7 @@ paths: delete: summary: "Remove a network" - operationId: "DeleteNetworks" + operationId: "NetworkDelete" responses: 204: description: "No error" @@ -6094,7 +6099,7 @@ paths: /networks/create: post: summary: "Create a network" - operationId: "NetworksCreate" + operationId: "NetworkCreate" consumes: - "application/json" produces: @@ -6190,7 +6195,7 @@ paths: /networks/{id}/connect: post: summary: "Connect a container to a network" - operationId: "NetworksConnect" + operationId: "NetworkConnect" consumes: - "application/octet-stream" responses: @@ -6236,7 +6241,7 @@ paths: /networks/{id}/disconnect: post: summary: "Disconnect a container from a network" - operationId: "NetworksDisconnect" + operationId: "NetworkDisconnect" consumes: - "application/json" responses: @@ -6296,12 +6301,11 @@ paths: description: "Server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Network" + tags: ["Network"] /plugins: get: summary: "List plugins" - operationId: "PluginsList" + operationId: "PluginList" description: "Returns information about installed plugins." produces: ["application/json"] responses: @@ -6390,14 +6394,14 @@ paths: description: "Server error" schema: $ref: "#/definitions/ErrorResponse" - tags: ["Plugins"] + tags: ["Plugin"] /plugins/pull: post: summary: "Install a plugin" - operationId: "PostPluginsPull" + operationId: "PluginPull" description: | - Pulls and installs a plugin. After the plugin is installed, it can be enabled using the [`POST /plugins/{name}/enable` endpoint](#operation/PostPluginsEnable). + Pulls and installs a plugin. After the plugin is installed, it can be enabled using the [`POST /plugins/{name}/enable` endpoint](#operation/PluginEnable). produces: - "application/json" responses: @@ -6447,12 +6451,11 @@ paths: in: "header" description: "A base64-encoded auth configuration to use when pulling a plugin from a registry. [See the authentication section for details.](#section/Authentication)" type: "string" - tags: - - "Plugins" + tags: ["Plugin"] /plugins/{name}: get: summary: "Inspect a plugin" - operationId: "GetPluginsInspect" + operationId: "PluginInspect" responses: 200: description: "no error" @@ -6472,11 +6475,10 @@ paths: description: "The name of the plugin. The `:latest` tag is optional, and is the default if omitted." required: true type: "string" - tags: - - "Plugins" + tags: ["Plugin"] delete: summary: "Remove a plugin" - operationId: "DeletePlugins" + operationId: "PluginDelete" responses: 200: description: "no error" @@ -6501,12 +6503,11 @@ paths: description: "Disable the plugin before removing. This may result in issues if the plugin is in use by a container." type: "boolean" default: false - tags: - - "Plugins" + tags: ["Plugin"] /plugins/{name}/enable: post: summary: "Enable a plugin" - operationId: "PostPluginsEnable" + operationId: "PluginEnable" responses: 200: description: "no error" @@ -6525,12 +6526,11 @@ paths: description: "Set the HTTP client timeout (in seconds)" type: "integer" default: 0 - tags: - - "Plugins" + tags: ["Plugin"] /plugins/{name}/disable: post: summary: "Disable a plugin" - operationId: "PostPluginsDisable" + operationId: "PluginDisable" responses: 200: description: "no error" @@ -6544,12 +6544,11 @@ paths: description: "The name of the plugin. The `:latest` tag is optional, and is the default if omitted." required: true type: "string" - tags: - - "Plugins" + tags: ["Plugin"] /plugins/create: post: summary: "Create a plugin" - operationId: "PostPluginsCreate" + operationId: "PluginCreate" consumes: - "application/x-tar" responses: @@ -6571,8 +6570,7 @@ paths: schema: type: "string" format: "binary" - tags: - - "Plugins" + tags: ["Plugin"] /plugins/{name}/push: post: summary: "Push a plugin" @@ -6596,12 +6594,11 @@ paths: description: "server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Plugins" + tags: ["Plugin"] /plugins/{name}/set: post: summary: "Configure a plugin" - operationId: "PostPluginsSet" + operationId: "PluginSet" consumes: - "application/json" parameters: @@ -6628,12 +6625,11 @@ paths: description: "Server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Plugins" + tags: ["Plugin"] /nodes: get: summary: "List nodes" - operationId: "GetNodesList" + operationId: "NodeList" responses: 200: description: "no error" @@ -6658,12 +6654,11 @@ paths: - `name=` - `role=`(`manager`|`worker`)` type: "string" - tags: - - "Nodes" + tags: ["Node"] /nodes/{id}: get: summary: "Inspect a node" - operationId: "GetNodesInspect" + operationId: "NodeInspect" responses: 200: description: "no error" @@ -6683,11 +6678,10 @@ paths: description: "The ID or name of the node" type: "string" required: true - tags: - - "Nodes" + tags: ["Node"] delete: summary: "Delete a node" - operationId: "DeleteNodes" + operationId: "NodeDelete" responses: 200: description: "no error" @@ -6710,12 +6704,11 @@ paths: description: "Force remove a node from the swarm" default: false type: "boolean" - tags: - - "Nodes" + tags: ["Node"] /nodes/{id}/update: post: summary: "Update a node" - operationId: "PostNodesUpdate" + operationId: "NodeUpdate" responses: 200: description: "no error" @@ -6743,12 +6736,11 @@ paths: type: "integer" format: "int64" required: true - tags: - - "Nodes" + tags: ["Node"] /swarm: get: summary: "Inspect swarm" - operationId: "GetSwarmInspect" + operationId: "SwarmInspect" responses: 200: description: "no error" @@ -6796,12 +6788,11 @@ paths: description: "server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Swarm" + tags: ["Swarm"] /swarm/init: post: summary: "Initialize a new swarm" - operationId: "PostSwarmInit" + operationId: "SwarmInit" produces: - "application/json" - "text/plain" @@ -6853,12 +6844,11 @@ paths: CAConfig: {} EncryptionConfig: AutoLockManagers: false - tags: - - "Swarm" + tags: ["Swarm"] /swarm/join: post: summary: "Join an existing swarm" - operationId: "PostSwarmJoin" + operationId: "SwarmJoin" responses: 200: description: "no error" @@ -6899,12 +6889,11 @@ paths: RemoteAddrs: - "node1:2377" JoinToken: "SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2" - tags: - - "Swarm" + tags: ["Swarm"] /swarm/leave: post: summary: "Leave a swarm" - operationId: "PostSwarmLeave" + operationId: "SwarmLeave" responses: 200: description: "no error" @@ -6922,12 +6911,11 @@ paths: in: "query" type: "boolean" default: false - tags: - - "Swarm" + tags: ["Swarm"] /swarm/update: post: summary: "Update a swarm" - operationId: "PostSwarmUpdate" + operationId: "SwarmUpdate" responses: 200: description: "no error" @@ -6970,8 +6958,7 @@ paths: description: "Rotate the manager unlock key." type: "boolean" default: false - tags: - - "Swarm" + tags: ["Swarm"] /swarm/unlockkey: get: summary: "Get the unlock key" @@ -6993,8 +6980,7 @@ paths: description: "server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Swarm" + tags: ["Swarm"] /swarm/unlock: post: summary: "Unlock a locked manager" @@ -7022,12 +7008,11 @@ paths: description: "server error" schema: $ref: "#/definitions/ErrorResponse" - tags: - - "Swarm" + tags: ["Swarm"] /services: get: summary: "List services" - operationId: "GetServicesList" + operationId: "ServiceList" responses: 200: description: "no error" @@ -7049,12 +7034,11 @@ paths: - `id=` - `name=` - `label=` - tags: - - "Services" + tags: ["Service"] /services/create: post: summary: "Create a service" - operationId: "PostServicesCreate" + operationId: "ServiceCreate" consumes: - "application/json" produces: @@ -7147,12 +7131,11 @@ paths: in: "header" description: "A base64-encoded auth configuration for pulling from private registries. [See the authentication section for details.](#section/Authentication)" type: "string" - tags: - - "Services" + tags: ["Service"] /services/{id}: get: summary: "Inspect a service" - operationId: "GetServicesInspect" + operationId: "ServiceInspect" responses: 200: description: "no error" @@ -7172,11 +7155,10 @@ paths: description: "ID or name of service." required: true type: "string" - tags: - - "Services" + tags: ["Service"] delete: summary: "Delete a service" - operationId: "DeleteServices" + operationId: "ServiceDelete" responses: 200: description: "no error" @@ -7194,8 +7176,7 @@ paths: description: "ID or name of service." required: true type: "string" - tags: - - "Services" + tags: ["Service"] /services/{id}/update: post: summary: "Update a service" @@ -7270,7 +7251,7 @@ paths: description: "A base64-encoded auth configuration for pulling from private registries. [See the authentication section for details.](#section/Authentication)" type: "string" - tags: ["Services"] + tags: ["Service"] /services/{id}/logs: get: summary: "Get service logs" @@ -7319,7 +7300,7 @@ paths: description: | Return the logs as a stream. - This will return a `101` HTTP response with a `Connection: upgrade` header, then hijack the HTTP connection to send raw output. For more information about hijacking and the stream format, [see the documentation for the attach endpoint](#operation/PostContainerAttach). + This will return a `101` HTTP response with a `Connection: upgrade` header, then hijack the HTTP connection to send raw output. For more information about hijacking and the stream format, [see the documentation for the attach endpoint](#operation/ContainerAttach). type: "boolean" default: false - name: "stdout" @@ -7347,12 +7328,11 @@ paths: description: "Only return this number of log lines from the end of the logs. Specify as an integer or `all` to output all log lines." type: "string" default: "all" - tags: - - "Services" + tags: ["Service"] /tasks: get: summary: "List tasks" - operationId: "GetTasksList" + operationId: "TaskList" produces: - "application/json" responses: @@ -7491,12 +7471,11 @@ paths: - `node=` - `label=key` or `label="key=value"` - `desired-state=(running | shutdown | accepted)` - tags: - - "Tasks" + tags: ["Task"] /tasks/{id}: get: summary: "Inspect a task" - operationId: "GetTasksInspect" + operationId: "TaskInspect" produces: - "application/json" responses: @@ -7518,8 +7497,7 @@ paths: description: "ID of the task" required: true type: "string" - tags: - - "Tasks" + tags: ["Task"] /secrets: get: summary: "List secrets" @@ -7553,8 +7531,7 @@ paths: A JSON encoded value of the filters (a `map[string][]string`) to process on the secrets list. Available filters: - `names=` - tags: - - "Secrets" + tags: ["Secret"] /secrets/create: post: summary: "Create a secret" @@ -7598,12 +7575,11 @@ paths: Labels: foo: "bar" Data: "VEhJUyBJUyBOT1QgQSBSRUFMIENFUlRJRklDQVRFCg==" - tags: - - "Secrets" + tags: ["Secret"] /secrets/{id}: get: summary: "Inspect a secret" - operationId: "SecretsInspect" + operationId: "SecretInspect" produces: - "application/json" responses: @@ -7637,11 +7613,10 @@ paths: required: true type: "string" description: "ID of the secret" - tags: - - "Secrets" + tags: ["Secret"] delete: summary: "Delete a secret" - operationId: "SecretsDelete" + operationId: "SecretDelete" produces: - "application/json" responses: @@ -7661,5 +7636,4 @@ paths: required: true type: "string" description: "ID of the secret" - tags: - - "Secrets" + tags: ["Secret"] diff --git a/builder/dockerfile/dispatchers.go b/builder/dockerfile/dispatchers.go index 64f0341d406fd818a61fa2fbeec7410665504652..32bbc42dbe84ebc835ffb1f7a3b4a4f2f7a358fd 100644 --- a/builder/dockerfile/dispatchers.go +++ b/builder/dockerfile/dispatchers.go @@ -71,14 +71,20 @@ func env(b *Builder, args []string, attributes map[string]bool, original string) if len(args[j]) == 0 { return errBlankCommandNames("ENV") } - newVar := args[j] + "=" + args[j+1] + "" commitStr += " " + newVar gotOne := false for i, envVar := range b.runConfig.Env { envParts := strings.SplitN(envVar, "=", 2) - if envParts[0] == args[j] { + compareFrom := envParts[0] + compareTo := args[j] + if runtime.GOOS == "windows" { + // Case insensitive environment variables on Windows + compareFrom = strings.ToUpper(compareFrom) + compareTo = strings.ToUpper(compareTo) + } + if compareFrom == compareTo { b.runConfig.Env[i] = newVar gotOne = true break diff --git a/builder/dockerfile/envVarTest b/builder/dockerfile/envVarTest index 1a7fe975a737d10f7504764c1fb2b2d65009842a..067dca9a54e1be4584ec16a790b72fb37a10f315 100644 --- a/builder/dockerfile/envVarTest +++ b/builder/dockerfile/envVarTest @@ -1,112 +1,116 @@ -hello | hello -he'll'o | hello -he'llo | hello -he\'llo | he'llo -he\\'llo | he\llo -abc\tdef | abctdef -"abc\tdef" | abc\tdef -'abc\tdef' | abc\tdef -hello\ | hello -hello\\ | hello\ -"hello | hello -"hello\" | hello" -"hel'lo" | hel'lo -'hello | hello -'hello\' | hello\ -"''" | '' -$. | $. -$1 | -he$1x | hex -he$.x | he$.x -he$pwd. | he. -he$PWD | he/home -he\$PWD | he$PWD -he\\$PWD | he\/home -he\${} | he${} -he\${}xx | he${}xx -he${} | he -he${}xx | hexx -he${hi} | he -he${hi}xx | hexx -he${PWD} | he/home -he${.} | error -he${XXX:-000}xx | he000xx -he${PWD:-000}xx | he/homexx -he${XXX:-$PWD}xx | he/homexx -he${XXX:-${PWD:-yyy}}xx | he/homexx -he${XXX:-${YYY:-yyy}}xx | heyyyxx -he${XXX:YYY} | error -he${XXX:+${PWD}}xx | hexx -he${PWD:+${XXX}}xx | hexx -he${PWD:+${SHELL}}xx | hebashxx -he${XXX:+000}xx | hexx -he${PWD:+000}xx | he000xx -'he${XX}' | he${XX} -"he${PWD}" | he/home -"he'$PWD'" | he'/home' -"$PWD" | /home -'$PWD' | $PWD -'\$PWD' | \$PWD -'"hello"' | "hello" -he\$PWD | he$PWD -"he\$PWD" | he$PWD -'he\$PWD' | he\$PWD -he${PWD | error -he${PWD:=000}xx | error -he${PWD:+${PWD}:}xx | he/home:xx -he${XXX:-\$PWD:}xx | he$PWD:xx -he${XXX:-\${PWD}z}xx | he${PWDz}xx -안녕하세요 | 안녕하세요 -안'녕'하세요 | 안녕하세요 -안'녕하세요 | 안녕하세요 -안녕\'하세요 | 안녕'하세요 -안\\'녕하세요 | 안\녕하세요 -안녕\t하세요 | 안녕t하세요 -"안녕\t하세요" | 안녕\t하세요 -'안녕\t하세요 | 안녕\t하세요 -안녕하세요\ | 안녕하세요 -안녕하세요\\ | 안녕하세요\ -"안녕하세요 | 안녕하세요 -"안녕하세요\" | 안녕하세요" -"안녕'하세요" | 안녕'하세요 -'안녕하세요 | 안녕하세요 -'안녕하세요\' | 안녕하세요\ -안녕$1x | 안녕x -안녕$.x | 안녕$.x -안녕$pwd. | 안녕. -안녕$PWD | 안녕/home -안녕\$PWD | 안녕$PWD -안녕\\$PWD | 안녕\/home -안녕\${} | 안녕${} -안녕\${}xx | 안녕${}xx -안녕${} | 안녕 -안녕${}xx | 안녕xx -안녕${hi} | 안녕 -안녕${hi}xx | 안녕xx -안녕${PWD} | 안녕/home -안녕${.} | error -안녕${XXX:-000}xx | 안녕000xx -안녕${PWD:-000}xx | 안녕/homexx -안녕${XXX:-$PWD}xx | 안녕/homexx -안녕${XXX:-${PWD:-yyy}}xx | 안녕/homexx -안녕${XXX:-${YYY:-yyy}}xx | 안녕yyyxx -안녕${XXX:YYY} | error -안녕${XXX:+${PWD}}xx | 안녕xx -안녕${PWD:+${XXX}}xx | 안녕xx -안녕${PWD:+${SHELL}}xx | 안녕bashxx -안녕${XXX:+000}xx | 안녕xx -안녕${PWD:+000}xx | 안녕000xx -'안녕${XX}' | 안녕${XX} -"안녕${PWD}" | 안녕/home -"안녕'$PWD'" | 안녕'/home' -'"안녕"' | "안녕" -안녕\$PWD | 안녕$PWD -"안녕\$PWD" | 안녕$PWD -'안녕\$PWD' | 안녕\$PWD -안녕${PWD | error -안녕${PWD:=000}xx | error -안녕${PWD:+${PWD}:}xx | 안녕/home:xx -안녕${XXX:-\$PWD:}xx | 안녕$PWD:xx -안녕${XXX:-\${PWD}z}xx | 안녕${PWDz}xx -$KOREAN | 한국어 -안녕$KOREAN | 안녕한국어 +A|hello | hello +A|he'll'o | hello +A|he'llo | hello +A|he\'llo | he'llo +A|he\\'llo | he\llo +A|abc\tdef | abctdef +A|"abc\tdef" | abc\tdef +A|'abc\tdef' | abc\tdef +A|hello\ | hello +A|hello\\ | hello\ +A|"hello | hello +A|"hello\" | hello" +A|"hel'lo" | hel'lo +A|'hello | hello +A|'hello\' | hello\ +A|"''" | '' +A|$. | $. +A|$1 | +A|he$1x | hex +A|he$.x | he$.x +# Next one is different on Windows as $pwd==$PWD +U|he$pwd. | he. +W|he$pwd. | he/home. +A|he$PWD | he/home +A|he\$PWD | he$PWD +A|he\\$PWD | he\/home +A|he\${} | he${} +A|he\${}xx | he${}xx +A|he${} | he +A|he${}xx | hexx +A|he${hi} | he +A|he${hi}xx | hexx +A|he${PWD} | he/home +A|he${.} | error +A|he${XXX:-000}xx | he000xx +A|he${PWD:-000}xx | he/homexx +A|he${XXX:-$PWD}xx | he/homexx +A|he${XXX:-${PWD:-yyy}}xx | he/homexx +A|he${XXX:-${YYY:-yyy}}xx | heyyyxx +A|he${XXX:YYY} | error +A|he${XXX:+${PWD}}xx | hexx +A|he${PWD:+${XXX}}xx | hexx +A|he${PWD:+${SHELL}}xx | hebashxx +A|he${XXX:+000}xx | hexx +A|he${PWD:+000}xx | he000xx +A|'he${XX}' | he${XX} +A|"he${PWD}" | he/home +A|"he'$PWD'" | he'/home' +A|"$PWD" | /home +A|'$PWD' | $PWD +A|'\$PWD' | \$PWD +A|'"hello"' | "hello" +A|he\$PWD | he$PWD +A|"he\$PWD" | he$PWD +A|'he\$PWD' | he\$PWD +A|he${PWD | error +A|he${PWD:=000}xx | error +A|he${PWD:+${PWD}:}xx | he/home:xx +A|he${XXX:-\$PWD:}xx | he$PWD:xx +A|he${XXX:-\${PWD}z}xx | he${PWDz}xx +A|안녕하세요 | 안녕하세요 +A|안'녕'하세요 | 안녕하세요 +A|안'녕하세요 | 안녕하세요 +A|안녕\'하세요 | 안녕'하세요 +A|안\\'녕하세요 | 안\녕하세요 +A|안녕\t하세요 | 안녕t하세요 +A|"안녕\t하세요" | 안녕\t하세요 +A|'안녕\t하세요 | 안녕\t하세요 +A|안녕하세요\ | 안녕하세요 +A|안녕하세요\\ | 안녕하세요\ +A|"안녕하세요 | 안녕하세요 +A|"안녕하세요\" | 안녕하세요" +A|"안녕'하세요" | 안녕'하세요 +A|'안녕하세요 | 안녕하세요 +A|'안녕하세요\' | 안녕하세요\ +A|안녕$1x | 안녕x +A|안녕$.x | 안녕$.x +# Next one is different on Windows as $pwd==$PWD +U|안녕$pwd. | 안녕. +W|안녕$pwd. | 안녕/home. +A|안녕$PWD | 안녕/home +A|안녕\$PWD | 안녕$PWD +A|안녕\\$PWD | 안녕\/home +A|안녕\${} | 안녕${} +A|안녕\${}xx | 안녕${}xx +A|안녕${} | 안녕 +A|안녕${}xx | 안녕xx +A|안녕${hi} | 안녕 +A|안녕${hi}xx | 안녕xx +A|안녕${PWD} | 안녕/home +A|안녕${.} | error +A|안녕${XXX:-000}xx | 안녕000xx +A|안녕${PWD:-000}xx | 안녕/homexx +A|안녕${XXX:-$PWD}xx | 안녕/homexx +A|안녕${XXX:-${PWD:-yyy}}xx | 안녕/homexx +A|안녕${XXX:-${YYY:-yyy}}xx | 안녕yyyxx +A|안녕${XXX:YYY} | error +A|안녕${XXX:+${PWD}}xx | 안녕xx +A|안녕${PWD:+${XXX}}xx | 안녕xx +A|안녕${PWD:+${SHELL}}xx | 안녕bashxx +A|안녕${XXX:+000}xx | 안녕xx +A|안녕${PWD:+000}xx | 안녕000xx +A|'안녕${XX}' | 안녕${XX} +A|"안녕${PWD}" | 안녕/home +A|"안녕'$PWD'" | 안녕'/home' +A|'"안녕"' | "안녕" +A|안녕\$PWD | 안녕$PWD +A|"안녕\$PWD" | 안녕$PWD +A|'안녕\$PWD' | 안녕\$PWD +A|안녕${PWD | error +A|안녕${PWD:=000}xx | error +A|안녕${PWD:+${PWD}:}xx | 안녕/home:xx +A|안녕${XXX:-\$PWD:}xx | 안녕$PWD:xx +A|안녕${XXX:-\${PWD}z}xx | 안녕${PWDz}xx +A|$KOREAN | 한국어 +A|안녕$KOREAN | 안녕한국어 diff --git a/builder/dockerfile/shell_parser.go b/builder/dockerfile/shell_parser.go index 3a095299a8e02bacde70d031330b61a2fd390c50..189afd1fdbe707b336ba6d326e2ab936d43075dd 100644 --- a/builder/dockerfile/shell_parser.go +++ b/builder/dockerfile/shell_parser.go @@ -8,6 +8,7 @@ package dockerfile import ( "fmt" + "runtime" "strings" "text/scanner" "unicode" @@ -298,9 +299,16 @@ func (sw *shellWord) processName() string { } func (sw *shellWord) getEnv(name string) string { + if runtime.GOOS == "windows" { + // Case-insensitive environment variables on Windows + name = strings.ToUpper(name) + } for _, env := range sw.envs { i := strings.Index(env, "=") if i < 0 { + if runtime.GOOS == "windows" { + env = strings.ToUpper(env) + } if name == env { // Should probably never get here, but just in case treat // it like "var" and "var=" are the same @@ -308,7 +316,11 @@ func (sw *shellWord) getEnv(name string) string { } continue } - if name != env[:i] { + compareName := env[:i] + if runtime.GOOS == "windows" { + compareName = strings.ToUpper(compareName) + } + if name != compareName { continue } return env[i+1:] diff --git a/builder/dockerfile/shell_parser_test.go b/builder/dockerfile/shell_parser_test.go index 35dea63fb1a5b6857b699e93a0637ba61a9a2c58..6cf691c077b406012b3302b313841e2c53c5cc15 100644 --- a/builder/dockerfile/shell_parser_test.go +++ b/builder/dockerfile/shell_parser_test.go @@ -3,12 +3,14 @@ package dockerfile import ( "bufio" "os" + "runtime" "strings" "testing" ) func TestShellParser4EnvVars(t *testing.T) { fn := "envVarTest" + lineCount := 0 file, err := os.Open(fn) if err != nil { @@ -20,6 +22,7 @@ func TestShellParser4EnvVars(t *testing.T) { envs := []string{"PWD=/home", "SHELL=bash", "KOREAN=한국어"} for scanner.Scan() { line := scanner.Text() + lineCount++ // Trim comments and blank lines i := strings.Index(line, "#") @@ -33,21 +36,30 @@ func TestShellParser4EnvVars(t *testing.T) { } words := strings.Split(line, "|") - if len(words) != 2 { + if len(words) != 3 { t.Fatalf("Error in '%s' - should be exactly one | in:%q", fn, line) } words[0] = strings.TrimSpace(words[0]) words[1] = strings.TrimSpace(words[1]) + words[2] = strings.TrimSpace(words[2]) - newWord, err := ProcessWord(words[0], envs, '\\') - - if err != nil { - newWord = "error" + // Key W=Windows; A=All; U=Unix + if (words[0] != "W") && (words[0] != "A") && (words[0] != "U") { + t.Fatalf("Invalid tag %s at line %d of %s. Must be W, A or U", words[0], lineCount, fn) } - if newWord != words[1] { - t.Fatalf("Error. Src: %s Calc: %s Expected: %s", words[0], newWord, words[1]) + if ((words[0] == "W" || words[0] == "A") && runtime.GOOS == "windows") || + ((words[0] == "U" || words[0] == "A") && runtime.GOOS != "windows") { + newWord, err := ProcessWord(words[1], envs, '\\') + + if err != nil { + newWord = "error" + } + + if newWord != words[2] { + t.Fatalf("Error. Src: %s Calc: %s Expected: %s at line %d", words[1], newWord, words[2], lineCount) + } } } } diff --git a/cli/command/node/ps.go b/cli/command/node/ps.go index 8591f046693f05bac4c5be9d30c6c01ec4b91ec9..a034721d244a63572dc9f8da7ec21a6b73ff6f7b 100644 --- a/cli/command/node/ps.go +++ b/cli/command/node/ps.go @@ -17,7 +17,6 @@ import ( type psOptions struct { nodeIDs []string - all bool noResolve bool noTrunc bool filter opts.FilterOpt @@ -44,7 +43,6 @@ func newPsCommand(dockerCli *command.DockerCli) *cobra.Command { flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate output") flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names") flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided") - flags.BoolVarP(&opts.all, "all", "a", false, "Show all tasks (default shows tasks that are or will be running)") return cmd } @@ -74,11 +72,6 @@ func runPs(dockerCli *command.DockerCli, opts psOptions) error { filter := opts.filter.Value() filter.Add("node", node.ID) - if !opts.all && !filter.Include("desired-state") { - filter.Add("desired-state", string(swarm.TaskStateRunning)) - filter.Add("desired-state", string(swarm.TaskStateAccepted)) - } - nodeTasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: filter}) if err != nil { errs = append(errs, err.Error()) diff --git a/cli/command/plugin/inspect.go b/cli/command/plugin/inspect.go index 13c7fa72d8e0506b282b6a08e4b8fc326be1afdc..46ec7b229b7b6ae2e2ea28d87929327c39cc9257 100644 --- a/cli/command/plugin/inspect.go +++ b/cli/command/plugin/inspect.go @@ -1,12 +1,9 @@ package plugin import ( - "fmt" - "github.com/docker/docker/cli" "github.com/docker/docker/cli/command" "github.com/docker/docker/cli/command/inspect" - "github.com/docker/docker/reference" "github.com/spf13/cobra" "golang.org/x/net/context" ) @@ -20,7 +17,7 @@ func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { var opts inspectOptions cmd := &cobra.Command{ - Use: "inspect [OPTIONS] PLUGIN [PLUGIN...]", + Use: "inspect [OPTIONS] PLUGIN|ID [PLUGIN|ID...]", Short: "Display detailed information on one or more plugins", Args: cli.RequiresMinArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -37,20 +34,8 @@ func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { client := dockerCli.Client() ctx := context.Background() - getRef := func(name string) (interface{}, []byte, error) { - named, err := reference.ParseNamed(name) // FIXME: validate - if err != nil { - return nil, nil, err - } - if reference.IsNameOnly(named) { - named = reference.WithDefaultTag(named) - } - ref, ok := named.(reference.NamedTagged) - if !ok { - return nil, nil, fmt.Errorf("invalid name: %s", named.String()) - } - - return client.PluginInspectWithRaw(ctx, ref.String()) + getRef := func(ref string) (interface{}, []byte, error) { + return client.PluginInspectWithRaw(ctx, ref) } return inspect.Inspect(dockerCli.Out(), opts.pluginNames, opts.format, getRef) diff --git a/cli/command/secret/create.go b/cli/command/secret/create.go index faef32ef8952a8a487c15431395c7f023c8ca4e1..381a931415e42a8cfb4b87f0cb4c89514527d670 100644 --- a/cli/command/secret/create.go +++ b/cli/command/secret/create.go @@ -25,9 +25,9 @@ func newSecretCreateCommand(dockerCli *command.DockerCli) *cobra.Command { } cmd := &cobra.Command{ - Use: "create [OPTIONS] SECRET [SECRET...]", + Use: "create [OPTIONS] SECRET", Short: "Create a secret using stdin as content", - Args: cli.RequiresMinArgs(1), + Args: cli.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { createOpts.name = args[0] return runSecretCreate(dockerCli, createOpts) diff --git a/cli/command/secret/inspect.go b/cli/command/secret/inspect.go index 1dda6f7838ff535ee108dd4c24ae5016c01bb8ed..0a8bd4a23fe3bcee5da7a647d9c10c06758c3d41 100644 --- a/cli/command/secret/inspect.go +++ b/cli/command/secret/inspect.go @@ -25,7 +25,7 @@ func newSecretInspectCommand(dockerCli *command.DockerCli) *cobra.Command { }, } - cmd.Flags().StringVarP(&opts.format, "format", "f", "", "Format the output using the given go template") + cmd.Flags().StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") return cmd } diff --git a/cli/command/secret/ls.go b/cli/command/secret/ls.go index d96b377867795cac0d3a2f7c418590180c1de601..faeab314b71fb7a570a7fa242d2baa9089e6db33 100644 --- a/cli/command/secret/ls.go +++ b/cli/command/secret/ls.go @@ -21,9 +21,10 @@ func newSecretListCommand(dockerCli *command.DockerCli) *cobra.Command { opts := listOptions{} cmd := &cobra.Command{ - Use: "ls [OPTIONS]", - Short: "List secrets", - Args: cli.NoArgs, + Use: "ls [OPTIONS]", + Aliases: []string{"list"}, + Short: "List secrets", + Args: cli.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { return runSecretList(dockerCli, opts) }, diff --git a/cli/command/secret/remove.go b/cli/command/secret/remove.go index 97d1f445cab3641fd16a22e6291d2d6986fb1590..f45a619f6aa835ec3fd976f80084f2006acf6de7 100644 --- a/cli/command/secret/remove.go +++ b/cli/command/secret/remove.go @@ -16,9 +16,10 @@ type removeOptions struct { func newSecretRemoveCommand(dockerCli *command.DockerCli) *cobra.Command { return &cobra.Command{ - Use: "rm SECRET [SECRET...]", - Short: "Remove one or more secrets", - Args: cli.RequiresMinArgs(1), + Use: "rm SECRET [SECRET...]", + Aliases: []string{"remove"}, + Short: "Remove one or more secrets", + Args: cli.RequiresMinArgs(1), RunE: func(cmd *cobra.Command, args []string) error { opts := removeOptions{ names: args, diff --git a/cli/command/service/ps.go b/cli/command/service/ps.go index 0028507c22e3bdbd198485243df97ae826dbf60c..cf94ad7374f540514aa1db215003d6616a086b26 100644 --- a/cli/command/service/ps.go +++ b/cli/command/service/ps.go @@ -2,7 +2,6 @@ package service import ( "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/cli" "github.com/docker/docker/cli/command" "github.com/docker/docker/cli/command/idresolver" @@ -15,7 +14,6 @@ import ( type psOptions struct { serviceID string - all bool quiet bool noResolve bool noTrunc bool @@ -39,7 +37,6 @@ func newPsCommand(dockerCli *command.DockerCli) *cobra.Command { flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate output") flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names") flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided") - flags.BoolVarP(&opts.all, "all", "a", false, "Show all tasks (default shows tasks that are or will be running)") return cmd } @@ -67,11 +64,6 @@ func runPS(dockerCli *command.DockerCli, opts psOptions) error { } } - if !opts.all && !filter.Include("desired-state") { - filter.Add("desired-state", string(swarm.TaskStateRunning)) - filter.Add("desired-state", string(swarm.TaskStateAccepted)) - } - tasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: filter}) if err != nil { return err diff --git a/cli/command/stack/common.go b/cli/command/stack/common.go index b94c10866739ce36e7b919032430aa8c2a66f449..920a1af0ccdcd2fd3cbd6acf47a57284086bdebf 100644 --- a/cli/command/stack/common.go +++ b/cli/command/stack/common.go @@ -37,7 +37,7 @@ func getServices( types.ServiceListOptions{Filters: getStackFilter(namespace)}) } -func getNetworks( +func getStackNetworks( ctx context.Context, apiclient client.APIClient, namespace string, diff --git a/cli/command/stack/deploy.go b/cli/command/stack/deploy.go index 9161c0965abbf26b2037badc87174db84d7e19e4..e7764f3b8d35217ea57b551256effda9ea1ace30 100644 --- a/cli/command/stack/deploy.go +++ b/cli/command/stack/deploy.go @@ -22,6 +22,7 @@ import ( "github.com/docker/docker/cli" "github.com/docker/docker/cli/command" servicecmd "github.com/docker/docker/cli/command/service" + dockerclient "github.com/docker/docker/client" "github.com/docker/docker/opts" runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/docker/go-connections/nat" @@ -123,7 +124,10 @@ func deployCompose(ctx context.Context, dockerCli *command.DockerCli, opts deplo namespace := namespace{name: opts.namespace} - networks := convertNetworks(namespace, config.Networks) + networks, externalNetworks := convertNetworks(namespace, config.Networks) + if err := validateExternalNetworks(ctx, dockerCli, externalNetworks); err != nil { + return err + } if err := createNetworks(ctx, dockerCli, namespace, networks); err != nil { return err } @@ -179,7 +183,7 @@ func getConfigFile(filename string) (*composetypes.ConfigFile, error) { func convertNetworks( namespace namespace, networks map[string]composetypes.NetworkConfig, -) map[string]types.NetworkCreate { +) (map[string]types.NetworkCreate, []string) { if networks == nil { networks = make(map[string]composetypes.NetworkConfig) } @@ -187,10 +191,12 @@ func convertNetworks( // TODO: only add default network if it's used networks["default"] = composetypes.NetworkConfig{} + externalNetworks := []string{} result := make(map[string]types.NetworkCreate) for internalName, network := range networks { - if network.External.Name != "" { + if network.External.External { + externalNetworks = append(externalNetworks, network.External.Name) continue } @@ -216,7 +222,29 @@ func convertNetworks( result[internalName] = createOpts } - return result + return result, externalNetworks +} + +func validateExternalNetworks( + ctx context.Context, + dockerCli *command.DockerCli, + externalNetworks []string) error { + client := dockerCli.Client() + + for _, networkName := range externalNetworks { + network, err := client.NetworkInspect(ctx, networkName) + if err != nil { + if dockerclient.IsErrNetworkNotFound(err) { + return fmt.Errorf("network %q is declared as external, but could not be found. You need to create the network before the stack is deployed (with overlay driver)", networkName) + } + return err + } + if network.Scope != "swarm" { + return fmt.Errorf("network %q is declared as external, but it is not in the right scope: %q instead of %q", networkName, network.Scope, "swarm") + } + } + + return nil } func createNetworks( @@ -227,7 +255,7 @@ func createNetworks( ) error { client := dockerCli.Client() - existingNetworks, err := getNetworks(ctx, client, namespace.name) + existingNetworks, err := getStackNetworks(ctx, client, namespace.name) if err != nil { return err } @@ -258,30 +286,39 @@ func createNetworks( func convertServiceNetworks( networks map[string]*composetypes.ServiceNetworkConfig, + networkConfigs map[string]composetypes.NetworkConfig, namespace namespace, name string, -) []swarm.NetworkAttachmentConfig { +) ([]swarm.NetworkAttachmentConfig, error) { if len(networks) == 0 { return []swarm.NetworkAttachmentConfig{ { Target: namespace.scope("default"), Aliases: []string{name}, }, - } + }, nil } nets := []swarm.NetworkAttachmentConfig{} for networkName, network := range networks { + networkConfig, ok := networkConfigs[networkName] + if !ok { + return []swarm.NetworkAttachmentConfig{}, fmt.Errorf("invalid network: %s", networkName) + } var aliases []string if network != nil { aliases = network.Aliases } + target := namespace.scope(networkName) + if networkConfig.External.External { + target = networkName + } nets = append(nets, swarm.NetworkAttachmentConfig{ - Target: namespace.scope(networkName), + Target: target, Aliases: append(aliases, name), }) } - return nets + return nets, nil } func convertVolumes( @@ -472,9 +509,10 @@ func convertServices( services := config.Services volumes := config.Volumes + networks := config.Networks for _, service := range services { - serviceSpec, err := convertService(namespace, service, volumes) + serviceSpec, err := convertService(namespace, service, networks, volumes) if err != nil { return nil, err } @@ -487,6 +525,7 @@ func convertServices( func convertService( namespace namespace, service composetypes.ServiceConfig, + networkConfigs map[string]composetypes.NetworkConfig, volumes map[string]composetypes.VolumeConfig, ) (swarm.ServiceSpec, error) { name := namespace.scope(service.Name) @@ -523,6 +562,11 @@ func convertService( return swarm.ServiceSpec{}, err } + networks, err := convertServiceNetworks(service.Networks, networkConfigs, namespace, service.Name) + if err != nil { + return swarm.ServiceSpec{}, err + } + serviceSpec := swarm.ServiceSpec{ Annotations: swarm.Annotations{ Name: name, @@ -553,7 +597,7 @@ func convertService( }, EndpointSpec: endpoint, Mode: mode, - Networks: convertServiceNetworks(service.Networks, namespace, service.Name), + Networks: networks, UpdateConfig: convertUpdateConfig(service.Deploy.UpdateConfig), } diff --git a/cli/command/stack/remove.go b/cli/command/stack/remove.go index 8137903d47440c998b26530f78c6c84b2d8e4938..734ff92a535a8dc110915d20141216daa9209bab 100644 --- a/cli/command/stack/remove.go +++ b/cli/command/stack/remove.go @@ -49,7 +49,7 @@ func runRemove(dockerCli *command.DockerCli, opts removeOptions) error { } } - networks, err := getNetworks(ctx, client, namespace) + networks, err := getStackNetworks(ctx, client, namespace) if err != nil { return err } diff --git a/container/stream/streams.go b/container/stream/streams.go index a45e31f21102b78117ba81bdd24657cd0e3818a0..79f366afdad02fc67d708bd1a191387cba18b416 100644 --- a/container/stream/streams.go +++ b/container/stream/streams.go @@ -135,7 +135,7 @@ func (c *Config) CopyToPipe(iop libcontainerd.IOPipe) { go func() { pools.Copy(iop.Stdin, stdin) if err := iop.Stdin.Close(); err != nil { - logrus.Errorf("failed to close stdin: %+v", err) + logrus.Warnf("failed to close stdin: %+v", err) } }() } diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 5f1a398aa7c0950139bdec32421d46fbbafae65c..63b1b2e653357245b9a63c55c77174dceafb9b8d 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -123,7 +123,7 @@ __docker_complete_container_ids() { COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") ) } -__docker_complete_images() { +__docker_images() { local images_args="" case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in @@ -152,8 +152,11 @@ __docker_complete_images() { ;; esac - local images=$(__docker_q images $images_args | awk "$awk_script") - COMPREPLY=( $(compgen -W "$images" -- "$cur") ) + __docker_q images $images_args | awk "$awk_script" | grep -v '$' +} + +__docker_complete_images() { + COMPREPLY=( $(compgen -W "$(__docker_images)" -- "$cur") ) __ltrim_colon_completions "$cur" } @@ -168,13 +171,6 @@ __docker_complete_image_repos_and_tags() { __ltrim_colon_completions "$cur" } -__docker_complete_containers_and_images() { - __docker_complete_containers_all - local containers=( "${COMPREPLY[@]}" ) - __docker_complete_images - COMPREPLY+=( "${containers[@]}" ) -} - # __docker_networks returns a list of all networks. Additional options to # `docker network ls` may be specified in order to filter the list, e.g. # `__docker_networks --filter type=custom` @@ -315,6 +311,22 @@ __docker_complete_runtimes() { COMPREPLY=( $(compgen -W "$(__docker_runtimes)" -- "$cur") ) } +# __docker_stacks returns a list of all stacks. +__docker_stacks() { + __docker_q stack ls | awk 'NR>1 {print $1}' +} + +# __docker_complete_stacks applies completion of stacks based on the current value +# of `$cur` or the value of the optional first option `--cur`, if given. +__docker_complete_stacks() { + local current="$cur" + if [ "$1" = "--cur" ] ; then + current="$2" + shift 2 + fi + COMPREPLY=( $(compgen -W "$(__docker_stacks "$@")" -- "$current") ) +} + # __docker_nodes returns a list of all nodes. Additional options to # `docker node ls` may be specified in order to filter the list, e.g. # `__docker_nodes --filter role=manager` @@ -397,6 +409,13 @@ __docker_append_to_completions() { COMPREPLY=( ${COMPREPLY[@]/%/"$1"} ) } +# __docker_is_experimental tests whether the currently configured Docker daemon +# runs in experimental mode. If so, the function exits with 0 (true). +# Otherwise, or if the result cannot be determined, the exit value is 1 (false). +__docker_is_experimental() { + [ "$(__docker_q version -f '{{.Server.Experimental}}')" = "true" ] +} + # __docker_pos_first_nonflag finds the position of the first word that is neither # option nor an option's argument. If there are options that require arguments, # you should pass a glob describing those options, e.g. "--option1|-o|--option2" @@ -839,6 +858,7 @@ _docker_docker() { *) local counter=$( __docker_pos_first_nonflag "$(__docker_to_extglob "$global_options_with_args")" ) if [ $cword -eq $counter ]; then + __docker_is_experimental && commands+=(${experimental_commands[*]}) COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) ) fi ;; @@ -1297,7 +1317,6 @@ _docker_container_run() { --memory-swap --memory-swappiness --memory-reservation - --mount --name --network --network-alias @@ -1863,6 +1882,10 @@ _docker_daemon() { esac } +_docker_deploy() { + __docker_is_experimental && _docker_stack_deploy +} + _docker_diff() { _docker_container_diff } @@ -2253,7 +2276,7 @@ _docker_inspect() { ;; --type) if [ -z "$preselected_type" ] ; then - COMPREPLY=( $( compgen -W "image container" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "container image network node service volume" -- "$cur" ) ) return fi ;; @@ -2270,7 +2293,14 @@ _docker_inspect() { *) case "$type" in '') - __docker_complete_containers_and_images + COMPREPLY=( $( compgen -W " + $(__docker_containers --all) + $(__docker_images) + $(__docker_networks) + $(__docker_nodes) + $(__docker_services) + $(__docker_volumes) + " -- "$cur" ) ) ;; container) __docker_complete_containers_all @@ -2278,6 +2308,18 @@ _docker_inspect() { image) __docker_complete_images ;; + network) + __docker_complete_networks + ;; + node) + __docker_complete_nodes + ;; + service) + __docker_complete_services + ;; + volume) + __docker_complete_volumes + ;; esac esac } @@ -2623,7 +2665,7 @@ _docker_service_ps() { case "$cur" in -*) - COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve --no-trunc --quiet -q" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "--filter -f --help --no-resolve --no-trunc --quiet -q" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--filter|-f') @@ -3318,6 +3360,166 @@ _docker_search() { esac } + +_docker_stack() { + local subcommands=" + deploy + ls + ps + rm + services + " + local aliases=" + down + list + remove + up + " + __docker_subcommands "$subcommands $aliases" && return + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) + ;; + esac +} + +_docker_stack_deploy() { + case "$prev" in + --bundle-file) + _filedir dab + return + ;; + --compose-file|-c) + _filedir yml + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--bundle-file --compose-file -c --help --with-registry-auth" -- "$cur" ) ) + ;; + esac +} + +_docker_stack_down() { + _docker_stack_rm +} + +_docker_stack_list() { + _docker_stack_ls +} + +_docker_stack_ls() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + esac +} + +_docker_stack_ps() { + local key=$(__docker_map_key_of_current_option '--filter|-f') + case "$key" in + desired-state) + COMPREPLY=( $( compgen -W "accepted running" -- "${cur##*=}" ) ) + return + ;; + id) + __docker_complete_stacks --cur "${cur##*=}" --id + return + ;; + name) + __docker_complete_stacks --cur "${cur##*=}" --name + return + ;; + esac + + case "$prev" in + --filter|-f) + COMPREPLY=( $( compgen -S = -W "id name desired-state" -- "$cur" ) ) + __docker_nospace + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve --no-trunc" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag '--filter|-f') + if [ $cword -eq $counter ]; then + __docker_complete_stacks + fi + ;; + esac +} + +_docker_stack_remove() { + _docker_stack_rm +} + +_docker_stack_rm() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_stacks + fi + ;; + esac +} + +_docker_stack_services() { + local key=$(__docker_map_key_of_current_option '--filter|-f') + case "$key" in + id) + __docker_complete_services --cur "${cur##*=}" --id + return + ;; + label) + return + ;; + name) + __docker_complete_services --cur "${cur##*=}" --name + return + ;; + esac + + case "$prev" in + --filter|-f) + COMPREPLY=( $( compgen -S = -W "id label name" -- "$cur" ) ) + __docker_nospace + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--filter -f --help --quiet -q" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag '--filter|-f') + if [ $cword -eq $counter ]; then + __docker_complete_stacks + fi + ;; + esac +} + +_docker_stack_up() { + _docker_stack_deploy +} + + _docker_start() { _docker_container_start } @@ -3651,6 +3853,7 @@ _docker() { save search service + stack start stats stop @@ -3665,6 +3868,10 @@ _docker() { wait ) + local experimental_commands=( + deploy + ) + # These options are valid as global options for all client commands # and valid as command options for `docker daemon` local global_boolean_options=" diff --git a/contrib/completion/fish/docker.fish b/contrib/completion/fish/docker.fish index 6630331b7bd34e6625fbbfd8f9f60707f9e6896d..2715cb1aa636ebcc1d5e33a27a3b70e71de4a7bd 100644 --- a/contrib/completion/fish/docker.fish +++ b/contrib/completion/fish/docker.fish @@ -137,7 +137,6 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l link -d 'Add complete -c docker -A -f -n '__fish_seen_subcommand_from create' -s m -l memory -d 'Memory limit (format: [], where unit = b, k, m or g)' complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l mac-address -d 'Container MAC address (e.g. 92:d0:c6:0a:29:33)' complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l memory-swap -d "Total memory usage (memory + swap), set '-1' to disable swap (format: [], where unit = b, k, m or g)" -complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l mount -d 'Attach a filesystem mount to the container' complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l name -d 'Assign a name to the container' complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l net -d 'Set the Network mode for the container' complete -c docker -A -f -n '__fish_seen_subcommand_from create' -s P -l publish-all -d 'Publish all exposed ports to random ports on the host interfaces' @@ -329,7 +328,6 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l link -d 'Add li complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s m -l memory -d 'Memory limit (format: [], where unit = b, k, m or g)' complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l mac-address -d 'Container MAC address (e.g. 92:d0:c6:0a:29:33)' complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l memory-swap -d "Total memory usage (memory + swap), set '-1' to disable swap (format: [], where unit = b, k, m or g)" -complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l mount -d 'Attach a filesystem mount to the container' complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l name -d 'Assign a name to the container' complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l net -d 'Set the Network mode for the container' complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s P -l publish-all -d 'Publish all exposed ports to random ports on the host interfaces' diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker index a65b7d9ffee001ce4991742b80bfbd0b675b11c5..5dfd1ef64c9ac44c68ee63b7990de0c8546f32b2 100644 --- a/contrib/completion/zsh/_docker +++ b/contrib/completion/zsh/_docker @@ -551,7 +551,6 @@ __docker_container_subcommand() { "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_complete_log_drivers" "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_complete_log_options" "($help)--mac-address=[Container MAC address]:MAC address: " - "($help)*--mount=[Attach a filesystem mount to the container]:mount: " "($help)--name=[Container name]:name: " "($help)--network=[Connect a container to a network]:network mode:(bridge none container host)" "($help)*--network-alias=[Add network-scoped alias for the container]:alias: " @@ -1883,6 +1882,147 @@ __docker_service_subcommand() { # EO service +# BO stack + +__docker_stack_complete_ps_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (desired-state) + state_opts=('accepted' 'running') + _describe -t state-opts "desired state options" state_opts && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('desired-state' 'id' 'name') + _describe -t filter-opts "filter options" opts -qS "=" && ret=0 + fi + + return ret +} + +__docker_stack_complete_services_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('id' 'label' 'name') + _describe -t filter-opts "filter options" opts -qS "=" && ret=0 + fi + + return ret +} + +__docker_stacks() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + local line s + declare -a lines stacks + + lines=(${(f)${:-"$(_call_program commands docker $docker_options stack ls)"$'\n'}}) + + # Parse header line to find columns + local i=1 j=1 k header=${lines[1]} + declare -A begin end + while (( j < ${#header} - 1 )); do + i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) + j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) + k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) + begin[${header[$i,$((j-1))]}]=$i + end[${header[$i,$((j-1))]}]=$k + done + end[${header[$i,$((j-1))]}]=-1 + lines=(${lines[2,-1]}) + + # Service ID + for line in $lines; do + s="${line[${begin[ID]},${end[ID]}]%% ##}" + stacks=($stacks $s) + done + + _describe -t stacks-list "stacks" stacks "$@" && ret=0 + return ret +} + +__docker_complete_stacks() { + [[ $PREFIX = -* ]] && return 1 + __docker_stacks "$@" +} + +__docker_stack_commands() { + local -a _docker_stack_subcommands + _docker_stack_subcommands=( + "deploy:Deploy a new stack or update an existing stack" + "ls:List stacks" + "ps:List the tasks in the stack" + "rm:Remove the stack" + "services:List the services in the stack" + ) + _describe -t docker-stack-commands "docker stack command" _docker_stack_subcommands +} + +__docker_stack_subcommand() { + local -a _command_args opts_help + local expl help="--help" + integer ret=1 + + opts_help=("(: -)--help[Print usage]") + + case "$words[1]" in + (deploy|up) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)--bundle-file=[Path to a Distributed Application Bundle file]:dab:_files -g \"*.dab\"" \ + "($help -c --compose-file)"{-c=,--compose-file=}"[Path to a Compose file]:compose file:_files -g \"*.(yml|yaml)\"" \ + "($help)--with-registry-auth[Send registry authentication details to Swarm agents]" \ + "($help -):stack:__docker_complete_stacks" && ret=0 + ;; + (ls|list) + _arguments $(__docker_arguments) \ + $opts_help && ret=0 + ;; + (ps) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -a --all)"{-a,--all}"[Display all tasks]" \ + "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_stack_complete_ps_filters" \ + "($help)--no-resolve[Do not map IDs to Names]" \ + "($help)--no-trunc[Do not truncate output]" \ + "($help -):stack:__docker_complete_stacks" && ret=0 + ;; + (rm|remove|down) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -):stack:__docker_complete_stacks" && ret=0 + ;; + (services) + _arguments $(__docker_arguments) \ + $opts_help \ + "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_stack_complete_services_filters" \ + "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" \ + "($help -):stack:__docker_complete_stacks" && ret=0 + ;; + (help) + _arguments $(__docker_arguments) ":subcommand:__docker_stack_commands" && ret=0 + ;; + esac + + return ret +} + +# EO stack + # BO swarm __docker_swarm_commands() { @@ -2451,6 +2591,23 @@ __docker_subcommand() { ;; esac ;; + (stack) + local curcontext="$curcontext" state + _arguments $(__docker_arguments) \ + $opts_help \ + "($help -): :->command" \ + "($help -)*:: :->option-or-argument" && ret=0 + + case $state in + (command) + __docker_stack_commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:docker-${words[-1]}: + __docker_stack_subcommand && ret=0 + ;; + esac + ;; (swarm) local curcontext="$curcontext" state _arguments $(__docker_arguments) \ diff --git a/daemon/cluster/cluster.go b/daemon/cluster/cluster.go index 8bb46a6998661e8daaf3e48b84a538b708e84dc8..b2afe15eefdb5c45c380b941528dba8be7a8a494 100644 --- a/daemon/cluster/cluster.go +++ b/daemon/cluster/cluster.go @@ -16,6 +16,7 @@ import ( "time" "github.com/Sirupsen/logrus" + "github.com/docker/distribution/digest" distreference "github.com/docker/distribution/reference" apierrors "github.com/docker/docker/api/errors" apitypes "github.com/docker/docker/api/types" @@ -1024,6 +1025,9 @@ func (c *Cluster) GetServices(options apitypes.ServiceListOptions) ([]types.Serv // TODO(nishanttotla): After the packages converge, the function must // convert distreference.Named -> distreference.Canonical, and the logic simplified. func (c *Cluster) imageWithDigestString(ctx context.Context, image string, authConfig *apitypes.AuthConfig) (string, error) { + if _, err := digest.ParseDigest(image); err == nil { + return "", errors.New("image reference is an image ID") + } ref, err := distreference.ParseNamed(image) if err != nil { return "", err diff --git a/daemon/cluster/convert/container.go b/daemon/cluster/convert/container.go index 8eb56b6eb708d7b9b0774dc3e34b6414f6e3f932..10383f749b3bf40d27b371173ddab0511f35b296 100644 --- a/daemon/cluster/convert/container.go +++ b/daemon/cluster/convert/container.go @@ -64,6 +64,13 @@ func containerSpecFromGRPC(c *swarmapi.ContainerSpec) types.ContainerSpec { } } } + + if m.TmpfsOptions != nil { + mount.TmpfsOptions = &mounttypes.TmpfsOptions{ + SizeBytes: m.TmpfsOptions.SizeBytes, + Mode: m.TmpfsOptions.Mode, + } + } containerSpec.Mounts = append(containerSpec.Mounts, mount) } @@ -174,9 +181,7 @@ func containerToGRPC(c types.ContainerSpec) (*swarmapi.ContainerSpec, error) { mount.BindOptions = &swarmapi.Mount_BindOptions{Propagation: swarmapi.Mount_BindOptions_MountPropagation(mountPropagation)} } else if string(m.BindOptions.Propagation) != "" { return nil, fmt.Errorf("invalid MountPropagation: %q", m.BindOptions.Propagation) - } - } if m.VolumeOptions != nil { @@ -192,6 +197,13 @@ func containerToGRPC(c types.ContainerSpec) (*swarmapi.ContainerSpec, error) { } } + if m.TmpfsOptions != nil { + mount.TmpfsOptions = &swarmapi.Mount_TmpfsOptions{ + SizeBytes: m.TmpfsOptions.SizeBytes, + Mode: m.TmpfsOptions.Mode, + } + } + containerSpec.Mounts = append(containerSpec.Mounts, mount) } diff --git a/daemon/cluster/executor/container/adapter.go b/daemon/cluster/executor/container/adapter.go index 010c18c5b315254fed3a2767f5e90f0214f0c0b4..1613b1d114d8a1a695015c133c8676827e1ca465 100644 --- a/daemon/cluster/executor/container/adapter.go +++ b/daemon/cluster/executor/container/adapter.go @@ -10,6 +10,7 @@ import ( "time" "github.com/Sirupsen/logrus" + "github.com/docker/distribution/digest" "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/backend" @@ -53,6 +54,11 @@ func newContainerAdapter(b executorpkg.Backend, task *api.Task, secrets exec.Sec func (c *containerAdapter) pullImage(ctx context.Context) error { spec := c.container.spec() + // Skip pulling if the image is referenced by image ID. + if _, err := digest.ParseDigest(spec.Image); err == nil { + return nil + } + // Skip pulling if the image is referenced by digest and already // exists locally. named, err := reference.ParseNamed(spec.Image) diff --git a/daemon/commit.go b/daemon/commit.go index ae6f51be3c8833d854adea1c25270c99fa6d08d5..333f7f2f938a70a4ec7c528bff92a7a2ecd56b7e 100644 --- a/daemon/commit.go +++ b/daemon/commit.go @@ -46,6 +46,11 @@ func merge(userConf, imageConf *containertypes.Config) error { imageEnvKey := strings.Split(imageEnv, "=")[0] for _, userEnv := range userConf.Env { userEnvKey := strings.Split(userEnv, "=")[0] + if runtime.GOOS == "windows" { + // Case insensitive environment variables on Windows + imageEnvKey = strings.ToUpper(imageEnvKey) + userEnvKey = strings.ToUpper(userEnvKey) + } if imageEnvKey == userEnvKey { found = true break diff --git a/daemon/container.go b/daemon/container.go index d27ed27dbf3a7045e8078bcd0b2ec1b004ce25c1..71fe06d592694e78068239827d75f2ca7a1f0faa 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -268,11 +268,11 @@ func (daemon *Daemon) verifyContainerSettings(hostConfig *containertypes.HostCon switch p.Name { case "always", "unless-stopped", "no": if p.MaximumRetryCount != 0 { - return nil, fmt.Errorf("maximum restart count not valid with restart policy of '%s'", p.Name) + return nil, fmt.Errorf("maximum retry count cannot be used with restart policy '%s'", p.Name) } case "on-failure": - if p.MaximumRetryCount < 1 { - return nil, fmt.Errorf("maximum restart count must be a positive integer") + if p.MaximumRetryCount < 0 { + return nil, fmt.Errorf("maximum retry count cannot be negative") } case "": // do nothing diff --git a/daemon/daemon.go b/daemon/daemon.go index 9de1411d5c1b9c9aeb11fcb97260b3e4cbbe7827..7c2ce505596b7b86542687f6abd8b46a395874a4 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -40,7 +40,6 @@ import ( "github.com/docker/docker/libcontainerd" "github.com/docker/docker/migrate/v1" "github.com/docker/docker/pkg/fileutils" - "github.com/docker/docker/pkg/graphdb" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/plugingetter" "github.com/docker/docker/pkg/progress" @@ -158,7 +157,6 @@ func (daemon *Daemon) restore() error { } } - var migrateLegacyLinks bool removeContainers := make(map[string]*container.Container) restartContainers := make(map[*container.Container]chan struct{}) activeSandboxes := make(map[string]interface{}) @@ -190,6 +188,8 @@ func (daemon *Daemon) restore() error { } } } + + var migrateLegacyLinks bool // Not relevant on Windows var wg sync.WaitGroup var mapLock sync.Mutex for _, c := range containers { @@ -265,24 +265,15 @@ func (daemon *Daemon) restore() error { return fmt.Errorf("Error initializing network controller: %v", err) } - // migrate any legacy links from sqlite - linkdbFile := filepath.Join(daemon.root, "linkgraph.db") - var legacyLinkDB *graphdb.Database + // Perform migration of legacy sqlite links (no-op on Windows) if migrateLegacyLinks { - legacyLinkDB, err = graphdb.NewSqliteConn(linkdbFile) - if err != nil { - return fmt.Errorf("error connecting to legacy link graph DB %s, container links may be lost: %v", linkdbFile, err) + if err := daemon.sqliteMigration(containers); err != nil { + return err } - defer legacyLinkDB.Close() } // Now that all the containers are registered, register the links for _, c := range containers { - if migrateLegacyLinks { - if err := daemon.migrateLegacySqliteLinks(legacyLinkDB, c); err != nil { - return err - } - } if err := daemon.registerLinks(c, c.HostConfig); err != nil { logrus.Errorf("failed to register link for container %s: %v", c.ID, err) } @@ -692,7 +683,11 @@ func NewDaemon(config *Config, registryService registry.Service, containerdRemot // set up SIGUSR1 handler on Unix-like systems, or a Win32 global event // on Windows to dump Go routine stacks - d.setupDumpStackTrap(config.Root) + stackDumpDir := config.Root + if execRoot := config.GetExecRoot(); execRoot != "" { + stackDumpDir = execRoot + } + d.setupDumpStackTrap(stackDumpDir) return d, nil } @@ -792,7 +787,13 @@ func (daemon *Daemon) Shutdown() error { }) } - // Shutdown plugins after containers. Dont change the order. + if daemon.layerStore != nil { + if err := daemon.layerStore.Cleanup(); err != nil { + logrus.Errorf("Error during layer Store.Cleanup(): %v", err) + } + } + + // Shutdown plugins after containers and layerstore. Don't change the order. daemon.pluginShutdown() // trigger libnetwork Stop only if it's initialized @@ -800,12 +801,6 @@ func (daemon *Daemon) Shutdown() error { daemon.netController.Stop() } - if daemon.layerStore != nil { - if err := daemon.layerStore.Cleanup(); err != nil { - logrus.Errorf("Error during layer Store.Cleanup(): %v", err) - } - } - if err := daemon.cleanupMounts(); err != nil { return err } diff --git a/daemon/links.go b/daemon/links.go index aaf1917d7c377bb871322ba581786d06364f5752..7f691d4f16fb912b26439f0acb98aae1427c06c7 100644 --- a/daemon/links.go +++ b/daemon/links.go @@ -1,12 +1,9 @@ package daemon import ( - "strings" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/docker/container" - "github.com/docker/docker/pkg/graphdb" ) // linkIndex stores link relationships between containers, including their specified alias @@ -88,41 +85,3 @@ func (l *linkIndex) delete(container *container.Container) { delete(l.childIdx, container) l.mu.Unlock() } - -// migrateLegacySqliteLinks migrates sqlite links to use links from HostConfig -// when sqlite links were used, hostConfig.Links was set to nil -func (daemon *Daemon) migrateLegacySqliteLinks(db *graphdb.Database, container *container.Container) error { - // if links is populated (or an empty slice), then this isn't using sqlite links and can be skipped - if container.HostConfig == nil || container.HostConfig.Links != nil { - return nil - } - - logrus.Debugf("migrating legacy sqlite link info for container: %s", container.ID) - - fullName := container.Name - if fullName[0] != '/' { - fullName = "/" + fullName - } - - // don't use a nil slice, this ensures that the check above will skip once the migration has completed - links := []string{} - children, err := db.Children(fullName, 0) - if err != nil { - if !strings.Contains(err.Error(), "Cannot find child for") { - return err - } - // else continue... it's ok if we didn't find any children, it'll just be nil and we can continue the migration - } - - for _, child := range children { - c, err := daemon.GetContainer(child.Entity.ID()) - if err != nil { - return err - } - - links = append(links, c.Name+":"+child.Edge.Name) - } - - container.HostConfig.Links = links - return container.WriteHostConfig() -} diff --git a/daemon/links_linux.go b/daemon/links_linux.go new file mode 100644 index 0000000000000000000000000000000000000000..2ea40d9e51ede8f7c17d6de1cfa87fe4c1432f1a --- /dev/null +++ b/daemon/links_linux.go @@ -0,0 +1,72 @@ +package daemon + +import ( + "fmt" + "path/filepath" + "strings" + + "github.com/Sirupsen/logrus" + "github.com/docker/docker/container" + "github.com/docker/docker/pkg/graphdb" +) + +// migrateLegacySqliteLinks migrates sqlite links to use links from HostConfig +// when sqlite links were used, hostConfig.Links was set to nil +func (daemon *Daemon) migrateLegacySqliteLinks(db *graphdb.Database, container *container.Container) error { + // if links is populated (or an empty slice), then this isn't using sqlite links and can be skipped + if container.HostConfig == nil || container.HostConfig.Links != nil { + return nil + } + + logrus.Debugf("migrating legacy sqlite link info for container: %s", container.ID) + + fullName := container.Name + if fullName[0] != '/' { + fullName = "/" + fullName + } + + // don't use a nil slice, this ensures that the check above will skip once the migration has completed + links := []string{} + children, err := db.Children(fullName, 0) + if err != nil { + if !strings.Contains(err.Error(), "Cannot find child for") { + return err + } + // else continue... it's ok if we didn't find any children, it'll just be nil and we can continue the migration + } + + for _, child := range children { + c, err := daemon.GetContainer(child.Entity.ID()) + if err != nil { + return err + } + + links = append(links, c.Name+":"+child.Edge.Name) + } + + container.HostConfig.Links = links + return container.WriteHostConfig() +} + +// sqliteMigration performs the link graph DB migration. +func (daemon *Daemon) sqliteMigration(containers map[string]*container.Container) error { + // migrate any legacy links from sqlite + linkdbFile := filepath.Join(daemon.root, "linkgraph.db") + var ( + legacyLinkDB *graphdb.Database + err error + ) + + legacyLinkDB, err = graphdb.NewSqliteConn(linkdbFile) + if err != nil { + return fmt.Errorf("error connecting to legacy link graph DB %s, container links may be lost: %v", linkdbFile, err) + } + defer legacyLinkDB.Close() + + for _, c := range containers { + if err := daemon.migrateLegacySqliteLinks(legacyLinkDB, c); err != nil { + return err + } + } + return nil +} diff --git a/daemon/links_test.go b/daemon/links_linux_test.go similarity index 100% rename from daemon/links_test.go rename to daemon/links_linux_test.go diff --git a/daemon/links_notlinux.go b/daemon/links_notlinux.go new file mode 100644 index 0000000000000000000000000000000000000000..12c226cfac7aa385681d0dfd4ad615cb78fe810e --- /dev/null +++ b/daemon/links_notlinux.go @@ -0,0 +1,10 @@ +// +build !linux + +package daemon + +import "github.com/docker/docker/container" + +// sqliteMigration performs the link graph DB migration. No-op on platforms other than Linux +func (daemon *Daemon) sqliteMigration(_ map[string]*container.Container) error { + return nil +} diff --git a/daemon/logger/logger.go b/daemon/logger/logger.go index 1ce7ed595d15c412c4d22cbbc09dd84d9061fc62..d0919973583b776543b08e5da0a7db073c033620 100644 --- a/daemon/logger/logger.go +++ b/daemon/logger/logger.go @@ -49,7 +49,7 @@ func CopyMessage(msg *Message) *Message { m.Timestamp = msg.Timestamp m.Partial = msg.Partial m.Attrs = make(LogAttributes) - for k, v := range m.Attrs { + for k, v := range msg.Attrs { m.Attrs[k] = v } return m diff --git a/daemon/logger/logger_test.go b/daemon/logger/logger_test.go new file mode 100644 index 0000000000000000000000000000000000000000..16e1514d2d01baa7339f02e133388ed89e8d1a6a --- /dev/null +++ b/daemon/logger/logger_test.go @@ -0,0 +1,26 @@ +package logger + +import ( + "reflect" + "testing" + "time" +) + +func TestCopyMessage(t *testing.T) { + msg := &Message{ + Line: []byte("test line."), + Source: "stdout", + Timestamp: time.Now(), + Attrs: LogAttributes{ + "key1": "val1", + "key2": "val2", + "key3": "val3", + }, + Partial: true, + } + + m := CopyMessage(msg) + if !reflect.DeepEqual(m, msg) { + t.Fatalf("CopyMessage failed to copy message") + } +} diff --git a/distribution/errors.go b/distribution/errors.go index ed8c3c05347f63cd97fcbb71c59a40fbe2b80e08..7f9e20f279d65ed283b524599d0f2c94813f3120 100644 --- a/distribution/errors.go +++ b/distribution/errors.go @@ -6,6 +6,7 @@ import ( "syscall" "github.com/Sirupsen/logrus" + "github.com/docker/distribution" "github.com/docker/distribution/registry/api/errcode" "github.com/docker/distribution/registry/api/v2" "github.com/docker/distribution/registry/client" @@ -139,6 +140,9 @@ func retryOnError(err error) error { case *client.UnexpectedHTTPResponseError: return xfer.DoNotRetry{Err: err} case error: + if err == distribution.ErrBlobUnknown { + return xfer.DoNotRetry{Err: err} + } if strings.Contains(err.Error(), strings.ToLower(syscall.ENOSPC.Error())) { return xfer.DoNotRetry{Err: err} } diff --git a/distribution/pull_v2.go b/distribution/pull_v2.go index d62200ddaa88aaffe8e33805fd03147b2e821102..5bfb328a18e4fc66a249d3e11f21491c09bac0f4 100644 --- a/distribution/pull_v2.go +++ b/distribution/pull_v2.go @@ -189,9 +189,6 @@ func (ld *v2LayerDescriptor) Download(ctx context.Context, progressOutput progre layerDownload, err := ld.open(ctx) if err != nil { logrus.Errorf("Error initiating layer download: %v", err) - if err == distribution.ErrBlobUnknown { - return nil, 0, xfer.DoNotRetry{Err: err} - } return nil, 0, retryOnError(err) } diff --git a/distribution/push_v2.go b/distribution/push_v2.go index f2a1f0271491a70d26c3ef8c5fb0c0c5cee22423..d72882b0d92d17c207f51b5369421ccc3755f6dc 100644 --- a/distribution/push_v2.go +++ b/distribution/push_v2.go @@ -523,6 +523,7 @@ func (pd *v2PushDescriptor) layerAlreadyExists( layerDigests = append(layerDigests, meta.Digest) } +attempts: for _, dgst := range layerDigests { meta := digestToMetadata[dgst] logrus.Debugf("Checking for presence of layer %s (%s) in %s", diffID, dgst, pd.repoInfo.FullName()) @@ -541,15 +542,14 @@ func (pd *v2PushDescriptor) layerAlreadyExists( } desc.MediaType = schema2.MediaTypeLayer exists = true - break + break attempts case distribution.ErrBlobUnknown: if meta.SourceRepository == pd.repoInfo.FullName() { // remove the mapping to the target repository pd.v2MetadataService.Remove(*meta) } default: - progress.Update(progressOutput, pd.ID(), "Image push failed") - return desc, false, retryOnError(err) + logrus.WithError(err).Debugf("Failed to check for presence of layer %s (%s) in %s", diffID, dgst, pd.repoInfo.FullName()) } } diff --git a/distribution/push_v2_test.go b/distribution/push_v2_test.go index b76e1a37332eb53307575085adadf7aa5d7b6cf0..c56f50bdaec447e8bf3ccb7eefddb0d476e44ed2 100644 --- a/distribution/push_v2_test.go +++ b/distribution/push_v2_test.go @@ -180,7 +180,7 @@ func TestLayerAlreadyExists(t *testing.T) { maxExistenceChecks: 1, metadata: []metadata.V2Metadata{{Digest: digest.Digest("apple"), SourceRepository: "docker.io/library/busybox"}}, remoteErrors: map[digest.Digest]error{digest.Digest("apple"): distribution.ErrAccessDenied}, - expectedError: distribution.ErrAccessDenied, + expectedError: nil, expectedRequests: []string{"apple"}, }, { @@ -310,7 +310,7 @@ func TestLayerAlreadyExists(t *testing.T) { expectedRemovals: []metadata.V2Metadata{taggedMetadata("key3", "apple", "docker.io/library/busybox")}, }, { - name: "stop on first error", + name: "don't stop on first error", targetRepo: "user/app", hmacKey: "key", metadata: []metadata.V2Metadata{ @@ -321,9 +321,12 @@ func TestLayerAlreadyExists(t *testing.T) { maxExistenceChecks: 3, remoteErrors: map[digest.Digest]error{"orange": distribution.ErrAccessDenied}, remoteBlobs: map[digest.Digest]distribution.Descriptor{digest.Digest("apple"): {}}, - expectedError: distribution.ErrAccessDenied, - expectedRequests: []string{"plum", "orange"}, - expectedRemovals: []metadata.V2Metadata{taggedMetadata("key", "plum", "docker.io/user/app")}, + expectedError: nil, + expectedRequests: []string{"plum", "orange", "banana"}, + expectedRemovals: []metadata.V2Metadata{ + taggedMetadata("key", "plum", "docker.io/user/app"), + taggedMetadata("key", "banana", "docker.io/user/app"), + }, }, { name: "remove outdated metadata", diff --git a/docs/api/v1.18.md b/docs/api/v1.18.md index bfffc9e0a5c47ff2129e699e22bf2fe1a60a3a1e..df063c20bcc571383385010580b60ce7004ab9d3 100644 --- a/docs/api/v1.18.md +++ b/docs/api/v1.18.md @@ -16,9 +16,7 @@ redirect_from: will be rejected. --> -# Docker Engine API v1.18 - -# 1. Brief introduction +## 1. Brief introduction - The daemon listens on `unix:///var/run/docker.sock` but you can [Bind Docker to another host/port or a Unix socket](../commandline/dockerd.md#bind-docker-to-another-host-port-or-a-unix-socket). @@ -26,11 +24,11 @@ redirect_from: or `pull`, the HTTP connection is hijacked to transport `STDOUT`, `STDIN` and `STDERR`. -# 2. Endpoints +## 2. Endpoints -## 2.1 Containers +### 2.1 Containers -### List containers +#### List containers `GET /containers/json` @@ -123,7 +121,7 @@ List containers - **400** – bad parameter - **500** – server error -### Create a container +#### Create a container `POST /containers/create` @@ -310,7 +308,7 @@ Create a container - **409** – conflict - **500** – server error -### Inspect a container +#### Inspect a container `GET /containers/(id or name)/json` @@ -443,7 +441,7 @@ Return low-level information on the container `id` - **404** – no such container - **500** – server error -### List processes running inside a container +#### List processes running inside a container `GET /containers/(id or name)/top` @@ -507,7 +505,7 @@ supported on Windows. - **404** – no such container - **500** – server error -### Get container logs +#### Get container logs `GET /containers/(id or name)/logs` @@ -547,7 +545,7 @@ Get `stdout` and `stderr` logs from the container ``id`` - **404** – no such container - **500** – server error -### Inspect changes on a container's filesystem +#### Inspect changes on a container's filesystem `GET /containers/(id or name)/changes` @@ -589,7 +587,7 @@ Values for `Kind`: - **404** – no such container - **500** – server error -### Export a container +#### Export a container `GET /containers/(id or name)/export` @@ -614,7 +612,7 @@ Export the contents of container `id` - **404** – no such container - **500** – server error -### Get container stats based on resource usage +#### Get container stats based on resource usage `GET /containers/(id or name)/stats` @@ -702,7 +700,7 @@ This endpoint returns a live stream of a container's resource usage statistics. - **404** – no such container - **500** – server error -### Resize a container TTY +#### Resize a container TTY `POST /containers/(id or name)/resize?h=&w=` @@ -729,7 +727,7 @@ Resize the TTY for container with `id`. You must restart the container for the - **404** – No such container - **500** – Cannot resize container -### Start a container +#### Start a container `POST /containers/(id or name)/start` @@ -754,7 +752,7 @@ Start the container `id` - **404** – no such container - **500** – server error -### Stop a container +#### Stop a container `POST /containers/(id or name)/stop` @@ -779,7 +777,7 @@ Stop the container `id` - **404** – no such container - **500** – server error -### Restart a container +#### Restart a container `POST /containers/(id or name)/restart` @@ -803,7 +801,7 @@ Restart the container `id` - **404** – no such container - **500** – server error -### Kill a container +#### Kill a container `POST /containers/(id or name)/kill` @@ -828,7 +826,7 @@ Kill the container `id` - **404** – no such container - **500** – server error -### Rename a container +#### Rename a container `POST /containers/(id or name)/rename` @@ -853,7 +851,7 @@ Rename the container `id` to a `new_name` - **409** - conflict name already assigned - **500** – server error -### Pause a container +#### Pause a container `POST /containers/(id or name)/pause` @@ -873,7 +871,7 @@ Pause the container `id` - **404** – no such container - **500** – server error -### Unpause a container +#### Unpause a container `POST /containers/(id or name)/unpause` @@ -893,7 +891,7 @@ Unpause the container `id` - **404** – no such container - **500** – server error -### Attach to a container +#### Attach to a container `POST /containers/(id or name)/attach` @@ -978,7 +976,7 @@ The simplest way to implement the Attach protocol is the following: 4. Read the extracted size and output it on the correct output. 5. Goto 1. -### Attach to a container (websocket) +#### Attach to a container (websocket) `GET /containers/(id or name)/attach/ws` @@ -1015,7 +1013,7 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet - **404** – no such container - **500** – server error -### Wait a container +#### Wait a container `POST /containers/(id or name)/wait` @@ -1038,7 +1036,7 @@ Block until container `id` stops, then returns the exit code - **404** – no such container - **500** – server error -### Remove a container +#### Remove a container `DELETE /containers/(id or name)` @@ -1067,7 +1065,7 @@ Remove the container `id` from the filesystem - **409** – conflict - **500** – server error -### Copy files or folders from a container +#### Copy files or folders from a container `POST /containers/(id or name)/copy` @@ -1097,9 +1095,9 @@ Copy files or folders of container `id` - **404** – no such container - **500** – server error -## 2.2 Images +### 2.2 Images -### List Images +#### List Images `GET /images/json` @@ -1185,7 +1183,7 @@ references on the command line. - `label=key` or `label="key=value"` of an image label - **filter** - only return images with the specified name -### Build image from a Dockerfile +#### Build image from a Dockerfile `POST /build` @@ -1256,7 +1254,7 @@ or being killed. - **200** – no error - **500** – server error -### Create an image +#### Create an image `POST /images/create` @@ -1300,7 +1298,7 @@ a base64-encoded AuthConfig object. -### Inspect an image +#### Inspect an image `GET /images/(name)/json` @@ -1351,7 +1349,7 @@ Return low-level information on the image `name` - **404** – no such image - **500** – server error -### Get the history of an image +#### Get the history of an image `GET /images/(name)/history` @@ -1385,7 +1383,7 @@ Return the history of the image `name` - **404** – no such image - **500** – server error -### Push an image on the registry +#### Push an image on the registry `POST /images/(name)/push` @@ -1428,7 +1426,7 @@ then be used in the URL. This duplicates the command line's flow. - **404** – no such image - **500** – server error -### Tag an image into a repository +#### Tag an image into a repository `POST /images/(name)/tag` @@ -1456,7 +1454,7 @@ Tag the image `name` into a repository - **409** – conflict - **500** – server error -### Remove an image +#### Remove an image `DELETE /images/(name)` @@ -1489,7 +1487,7 @@ Remove the image `name` from the filesystem - **409** – conflict - **500** – server error -### Search images +#### Search images `GET /images/search` @@ -1542,9 +1540,9 @@ Search for an image on [Docker Hub](https://hub.docker.com). - **200** – no error - **500** – server error -## 2.3 Misc +### 2.3 Misc -### Check auth configuration +#### Check auth configuration `POST /auth` @@ -1572,7 +1570,7 @@ Get the default username and email - **204** – no error - **500** – server error -### Display system-wide information +#### Display system-wide information `GET /info` @@ -1637,7 +1635,7 @@ Display system-wide information - **200** – no error - **500** – server error -### Show the docker version information +#### Show the docker version information `GET /version` @@ -1667,7 +1665,7 @@ Show the docker version information - **200** – no error - **500** – server error -### Ping the docker server +#### Ping the docker server `GET /_ping` @@ -1689,7 +1687,7 @@ Ping the docker server - **200** - no error - **500** - server error -### Create a new image from a container's changes +#### Create a new image from a container's changes `POST /commit` @@ -1751,7 +1749,7 @@ Create a new image from a container's changes - **404** – no such container - **500** – server error -### Monitor Docker's events +#### Monitor Docker's events `GET /events` @@ -1793,7 +1791,7 @@ Docker images report the following events: - **200** – no error - **500** – server error -### Get a tarball containing all images in a repository +#### Get a tarball containing all images in a repository `GET /images/(name)/get` @@ -1823,7 +1821,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Get a tarball containing all images +#### Get a tarball containing all images `GET /images/get` @@ -1852,7 +1850,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Load a tarball with a set of images and tags into docker +#### Load a tarball with a set of images and tags into docker `POST /images/load` @@ -1875,7 +1873,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Image tarball format +#### Image tarball format An image tarball contains one directory per image layer (named using its long ID), each containing these files: @@ -1896,7 +1894,7 @@ the root that contains a list of repository and tag names mapped to layer IDs. } ``` -### Exec Create +#### Exec Create `POST /containers/(id or name)/exec` @@ -1939,7 +1937,7 @@ Sets up an exec instance in a running container `id` - **201** – no error - **404** – no such container -### Exec Start +#### Exec Start `POST /exec/(id)/start` @@ -1980,7 +1978,7 @@ interactive session with the `exec` command. Similar to the stream behavior of `POST /containers/(id or name)/attach` API -### Exec Resize +#### Exec Resize `POST /exec/(id)/resize` @@ -2007,7 +2005,7 @@ This API is valid only if `tty` was specified as part of creating and starting t - **201** – no error - **404** – no such exec instance -### Exec Inspect +#### Exec Inspect `GET /exec/(id)/json` @@ -2112,9 +2110,9 @@ Return low-level information about the `exec` command `id`. - **404** – no such exec instance - **500** - server error -# 3. Going further +## 3. Going further -## 3.1 Inside `docker run` +### 3.1 Inside `docker run` As an example, the `docker run` command line makes the following API calls: @@ -2132,7 +2130,7 @@ As an example, the `docker run` command line makes the following API calls: - If in detached mode or only `stdin` is attached, display the container's id. -## 3.2 Hijacking +### 3.2 Hijacking In this version of the API, `/attach`, uses hijacking to transport `stdin`, `stdout`, and `stderr` on the same socket. @@ -2148,7 +2146,7 @@ from **200 OK** to **101 UPGRADED** and resends the same headers. This might change in the future. -## 3.3 CORS Requests +### 3.3 CORS Requests To set cross origin requests to the Engine API please give values to `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, diff --git a/docs/api/v1.19.md b/docs/api/v1.19.md index b20f1d7b85586422b1336a58829cdf9ebcaba114..d22c158d899dacf055b900129380a2e858fac682 100644 --- a/docs/api/v1.19.md +++ b/docs/api/v1.19.md @@ -16,8 +16,6 @@ redirect_from: will be rejected. --> -# Docker Engine API v1.19 - ## 1. Brief introduction - The daemon listens on `unix:///var/run/docker.sock` but you can @@ -28,11 +26,11 @@ redirect_from: - When the client API version is newer than the daemon's, these calls return an HTTP `400 Bad Request` error message. -# 2. Endpoints +## 2. Endpoints -## 2.1 Containers +### 2.1 Containers -### List containers +#### List containers `GET /containers/json` @@ -125,7 +123,7 @@ List containers - **400** – bad parameter - **500** – server error -### Create a container +#### Create a container `POST /containers/create` @@ -322,7 +320,7 @@ Create a container - **409** – conflict - **500** – server error -### Inspect a container +#### Inspect a container `GET /containers/(id or name)/json` @@ -459,7 +457,7 @@ Return low-level information on the container `id` - **404** – no such container - **500** – server error -### List processes running inside a container +#### List processes running inside a container `GET /containers/(id or name)/top` @@ -523,7 +521,7 @@ supported on Windows. - **404** – no such container - **500** – server error -### Get container logs +#### Get container logs `GET /containers/(id or name)/logs` @@ -565,7 +563,7 @@ Get `stdout` and `stderr` logs from the container ``id`` - **404** – no such container - **500** – server error -### Inspect changes on a container's filesystem +#### Inspect changes on a container's filesystem `GET /containers/(id or name)/changes` @@ -607,7 +605,7 @@ Values for `Kind`: - **404** – no such container - **500** – server error -### Export a container +#### Export a container `GET /containers/(id or name)/export` @@ -632,7 +630,7 @@ Export the contents of container `id` - **404** – no such container - **500** – server error -### Get container stats based on resource usage +#### Get container stats based on resource usage `GET /containers/(id or name)/stats` @@ -741,7 +739,7 @@ The precpu_stats is the cpu statistic of last read, which is used for calculatin - **404** – no such container - **500** – server error -### Resize a container TTY +#### Resize a container TTY `POST /containers/(id or name)/resize?h=&w=` @@ -768,7 +766,7 @@ Resize the TTY for container with `id`. You must restart the container for the - **404** – No such container - **500** – Cannot resize container -### Start a container +#### Start a container `POST /containers/(id or name)/start` @@ -793,7 +791,7 @@ Start the container `id` - **404** – no such container - **500** – server error -### Stop a container +#### Stop a container `POST /containers/(id or name)/stop` @@ -818,7 +816,7 @@ Stop the container `id` - **404** – no such container - **500** – server error -### Restart a container +#### Restart a container `POST /containers/(id or name)/restart` @@ -842,7 +840,7 @@ Restart the container `id` - **404** – no such container - **500** – server error -### Kill a container +#### Kill a container `POST /containers/(id or name)/kill` @@ -867,7 +865,7 @@ Kill the container `id` - **404** – no such container - **500** – server error -### Rename a container +#### Rename a container `POST /containers/(id or name)/rename` @@ -892,7 +890,7 @@ Rename the container `id` to a `new_name` - **409** - conflict name already assigned - **500** – server error -### Pause a container +#### Pause a container `POST /containers/(id or name)/pause` @@ -912,7 +910,7 @@ Pause the container `id` - **404** – no such container - **500** – server error -### Unpause a container +#### Unpause a container `POST /containers/(id or name)/unpause` @@ -932,7 +930,7 @@ Unpause the container `id` - **404** – no such container - **500** – server error -### Attach to a container +#### Attach to a container `POST /containers/(id or name)/attach` @@ -1017,7 +1015,7 @@ The simplest way to implement the Attach protocol is the following: 4. Read the extracted size and output it on the correct output. 5. Goto 1. -### Attach to a container (websocket) +#### Attach to a container (websocket) `GET /containers/(id or name)/attach/ws` @@ -1054,7 +1052,7 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet - **404** – no such container - **500** – server error -### Wait a container +#### Wait a container `POST /containers/(id or name)/wait` @@ -1077,7 +1075,7 @@ Block until container `id` stops, then returns the exit code - **404** – no such container - **500** – server error -### Remove a container +#### Remove a container `DELETE /containers/(id or name)` @@ -1106,7 +1104,7 @@ Remove the container `id` from the filesystem - **409** – conflict - **500** – server error -### Copy files or folders from a container +#### Copy files or folders from a container `POST /containers/(id or name)/copy` @@ -1136,9 +1134,9 @@ Copy files or folders of container `id` - **404** – no such container - **500** – server error -## 2.2 Images +### 2.2 Images -### List Images +#### List Images `GET /images/json` @@ -1229,7 +1227,7 @@ references on the command line. - `label=key` or `label="key=value"` of an image label - **filter** - only return images with the specified name -### Build image from a Dockerfile +#### Build image from a Dockerfile `POST /build` @@ -1302,7 +1300,7 @@ or being killed. - **200** – no error - **500** – server error -### Create an image +#### Create an image `POST /images/create` @@ -1346,7 +1344,7 @@ a base64-encoded AuthConfig object. -### Inspect an image +#### Inspect an image `GET /images/(name)/json` @@ -1397,7 +1395,7 @@ Return low-level information on the image `name` - **404** – no such image - **500** – server error -### Get the history of an image +#### Get the history of an image `GET /images/(name)/history` @@ -1451,7 +1449,7 @@ Return the history of the image `name` - **404** – no such image - **500** – server error -### Push an image on the registry +#### Push an image on the registry `POST /images/(name)/push` @@ -1494,7 +1492,7 @@ then be used in the URL. This duplicates the command line's flow. - **404** – no such image - **500** – server error -### Tag an image into a repository +#### Tag an image into a repository `POST /images/(name)/tag` @@ -1522,7 +1520,7 @@ Tag the image `name` into a repository - **409** – conflict - **500** – server error -### Remove an image +#### Remove an image `DELETE /images/(name)` @@ -1555,7 +1553,7 @@ Remove the image `name` from the filesystem - **409** – conflict - **500** – server error -### Search images +#### Search images `GET /images/search` @@ -1614,9 +1612,9 @@ be deprecated and replaced by the `is_automated` property. - **200** – no error - **500** – server error -## 2.3 Misc +### 2.3 Misc -### Check auth configuration +#### Check auth configuration `POST /auth` @@ -1644,7 +1642,7 @@ Get the default username and email - **204** – no error - **500** – server error -### Display system-wide information +#### Display system-wide information `GET /info` @@ -1713,7 +1711,7 @@ Display system-wide information - **200** – no error - **500** – server error -### Show the docker version information +#### Show the docker version information `GET /version` @@ -1743,7 +1741,7 @@ Show the docker version information - **200** – no error - **500** – server error -### Ping the docker server +#### Ping the docker server `GET /_ping` @@ -1765,7 +1763,7 @@ Ping the docker server - **200** - no error - **500** - server error -### Create a new image from a container's changes +#### Create a new image from a container's changes `POST /commit` @@ -1831,7 +1829,7 @@ Create a new image from a container's changes - **404** – no such container - **500** – server error -### Monitor Docker's events +#### Monitor Docker's events `GET /events` @@ -1873,7 +1871,7 @@ Docker images report the following events: - **200** – no error - **500** – server error -### Get a tarball containing all images in a repository +#### Get a tarball containing all images in a repository `GET /images/(name)/get` @@ -1903,7 +1901,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Get a tarball containing all images +#### Get a tarball containing all images `GET /images/get` @@ -1932,7 +1930,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Load a tarball with a set of images and tags into docker +#### Load a tarball with a set of images and tags into docker `POST /images/load` @@ -1955,7 +1953,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Image tarball format +#### Image tarball format An image tarball contains one directory per image layer (named using its long ID), each containing these files: @@ -1976,7 +1974,7 @@ the root that contains a list of repository and tag names mapped to layer IDs. } ``` -### Exec Create +#### Exec Create `POST /containers/(id or name)/exec` @@ -2022,7 +2020,7 @@ Sets up an exec instance in a running container `id` - **201** – no error - **404** – no such container -### Exec Start +#### Exec Start `POST /exec/(id)/start` @@ -2063,7 +2061,7 @@ interactive session with the `exec` command. Similar to the stream behavior of `POST /containers/(id or name)/attach` API -### Exec Resize +#### Exec Resize `POST /exec/(id)/resize` @@ -2090,7 +2088,7 @@ This API is valid only if `tty` was specified as part of creating and starting t - **201** – no error - **404** – no such exec instance -### Exec Inspect +#### Exec Inspect `GET /exec/(id)/json` @@ -2195,9 +2193,9 @@ Return low-level information about the `exec` command `id`. - **404** – no such exec instance - **500** - server error -# 3. Going further +## 3. Going further -## 3.1 Inside `docker run` +### 3.1 Inside `docker run` As an example, the `docker run` command line makes the following API calls: @@ -2215,7 +2213,7 @@ As an example, the `docker run` command line makes the following API calls: - If in detached mode or only `stdin` is attached, display the container's id. -## 3.2 Hijacking +### 3.2 Hijacking In this version of the API, `/attach`, uses hijacking to transport `stdin`, `stdout`, and `stderr` on the same socket. @@ -2230,7 +2228,7 @@ When Docker daemon detects the `Upgrade` header, it switches its status code from **200 OK** to **101 UPGRADED** and resends the same headers. -## 3.3 CORS Requests +### 3.3 CORS Requests To set cross origin requests to the Engine API please give values to `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, diff --git a/docs/api/v1.20.md b/docs/api/v1.20.md index 1f093f3ccc1ca065e68b0edb987bbee048232ea3..ab83b3eca164999daff7e9b6cdbaf23f8aaad142 100644 --- a/docs/api/v1.20.md +++ b/docs/api/v1.20.md @@ -16,9 +16,7 @@ redirect_from: will be rejected. --> -# Docker Engine API v1.20 - -# 1. Brief introduction +## 1. Brief introduction - The daemon listens on `unix:///var/run/docker.sock` but you can [Bind Docker to another host/port or a Unix socket](../commandline/dockerd.md#bind-docker-to-another-host-port-or-a-unix-socket). @@ -26,11 +24,11 @@ redirect_from: or `pull`, the HTTP connection is hijacked to transport `stdout`, `stdin` and `stderr`. -# 2. Endpoints +## 2. Endpoints -## 2.1 Containers +### 2.1 Containers -### List containers +#### List containers `GET /containers/json` @@ -123,7 +121,7 @@ List containers - **400** – bad parameter - **500** – server error -### Create a container +#### Create a container `POST /containers/create` @@ -324,7 +322,7 @@ Create a container - **409** – conflict - **500** – server error -### Inspect a container +#### Inspect a container `GET /containers/(id or name)/json` @@ -466,7 +464,7 @@ Return low-level information on the container `id` - **404** – no such container - **500** – server error -### List processes running inside a container +#### List processes running inside a container `GET /containers/(id or name)/top` @@ -530,7 +528,7 @@ supported on Windows. - **404** – no such container - **500** – server error -### Get container logs +#### Get container logs `GET /containers/(id or name)/logs` @@ -572,7 +570,7 @@ Get `stdout` and `stderr` logs from the container ``id`` - **404** – no such container - **500** – server error -### Inspect changes on a container's filesystem +#### Inspect changes on a container's filesystem `GET /containers/(id or name)/changes` @@ -614,7 +612,7 @@ Values for `Kind`: - **404** – no such container - **500** – server error -### Export a container +#### Export a container `GET /containers/(id or name)/export` @@ -639,7 +637,7 @@ Export the contents of container `id` - **404** – no such container - **500** – server error -### Get container stats based on resource usage +#### Get container stats based on resource usage `GET /containers/(id or name)/stats` @@ -748,7 +746,7 @@ The precpu_stats is the cpu statistic of last read, which is used for calculatin - **404** – no such container - **500** – server error -### Resize a container TTY +#### Resize a container TTY `POST /containers/(id or name)/resize?h=&w=` @@ -775,7 +773,7 @@ Resize the TTY for container with `id`. You must restart the container for the - **404** – No such container - **500** – Cannot resize container -### Start a container +#### Start a container `POST /containers/(id or name)/start` @@ -800,7 +798,7 @@ Start the container `id` - **404** – no such container - **500** – server error -### Stop a container +#### Stop a container `POST /containers/(id or name)/stop` @@ -825,7 +823,7 @@ Stop the container `id` - **404** – no such container - **500** – server error -### Restart a container +#### Restart a container `POST /containers/(id or name)/restart` @@ -849,7 +847,7 @@ Restart the container `id` - **404** – no such container - **500** – server error -### Kill a container +#### Kill a container `POST /containers/(id or name)/kill` @@ -874,7 +872,7 @@ Kill the container `id` - **404** – no such container - **500** – server error -### Rename a container +#### Rename a container `POST /containers/(id or name)/rename` @@ -899,7 +897,7 @@ Rename the container `id` to a `new_name` - **409** - conflict name already assigned - **500** – server error -### Pause a container +#### Pause a container `POST /containers/(id or name)/pause` @@ -919,7 +917,7 @@ Pause the container `id` - **404** – no such container - **500** – server error -### Unpause a container +#### Unpause a container `POST /containers/(id or name)/unpause` @@ -939,7 +937,7 @@ Unpause the container `id` - **404** – no such container - **500** – server error -### Attach to a container +#### Attach to a container `POST /containers/(id or name)/attach` @@ -1024,7 +1022,7 @@ The simplest way to implement the Attach protocol is the following: 4. Read the extracted size and output it on the correct output. 5. Goto 1. -### Attach to a container (websocket) +#### Attach to a container (websocket) `GET /containers/(id or name)/attach/ws` @@ -1061,7 +1059,7 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet - **404** – no such container - **500** – server error -### Wait a container +#### Wait a container `POST /containers/(id or name)/wait` @@ -1084,7 +1082,7 @@ Block until container `id` stops, then returns the exit code - **404** – no such container - **500** – server error -### Remove a container +#### Remove a container `DELETE /containers/(id or name)` @@ -1113,7 +1111,7 @@ Remove the container `id` from the filesystem - **409** – conflict - **500** – server error -### Copy files or folders from a container +#### Copy files or folders from a container `POST /containers/(id or name)/copy` @@ -1145,14 +1143,14 @@ Copy files or folders of container `id` - **404** – no such container - **500** – server error -### Retrieving information about files and folders in a container +#### Retrieving information about files and folders in a container `HEAD /containers/(id or name)/archive` See the description of the `X-Docker-Container-Path-Stat` header in the following section. -### Get an archive of a filesystem resource in a container +#### Get an archive of a filesystem resource in a container `GET /containers/(id or name)/archive` @@ -1217,7 +1215,7 @@ desired. - no such file or directory (**path** does not exist) - **500** - server error -### Extract an archive of files or folders to a directory in a container +#### Extract an archive of files or folders to a directory in a container `PUT /containers/(id or name)/archive` @@ -1265,9 +1263,9 @@ Upload a tar archive to be extracted to a path in the filesystem of container - no such file or directory (**path** resource does not exist) - **500** – server error -## 2.2 Images +### 2.2 Images -### List Images +#### List Images `GET /images/json` @@ -1358,7 +1356,7 @@ references on the command line. - `label=key` or `label="key=value"` of an image label - **filter** - only return images with the specified name -### Build image from a Dockerfile +#### Build image from a Dockerfile `POST /build` @@ -1456,7 +1454,7 @@ or being killed. - **200** – no error - **500** – server error -### Create an image +#### Create an image `POST /images/create` @@ -1500,7 +1498,7 @@ a base64-encoded AuthConfig object. -### Inspect an image +#### Inspect an image `GET /images/(name)/json` @@ -1551,7 +1549,7 @@ Return low-level information on the image `name` - **404** – no such image - **500** – server error -### Get the history of an image +#### Get the history of an image `GET /images/(name)/history` @@ -1605,7 +1603,7 @@ Return the history of the image `name` - **404** – no such image - **500** – server error -### Push an image on the registry +#### Push an image on the registry `POST /images/(name)/push` @@ -1648,7 +1646,7 @@ then be used in the URL. This duplicates the command line's flow. - **404** – no such image - **500** – server error -### Tag an image into a repository +#### Tag an image into a repository `POST /images/(name)/tag` @@ -1676,7 +1674,7 @@ Tag the image `name` into a repository - **409** – conflict - **500** – server error -### Remove an image +#### Remove an image `DELETE /images/(name)` @@ -1709,7 +1707,7 @@ Remove the image `name` from the filesystem - **409** – conflict - **500** – server error -### Search images +#### Search images `GET /images/search` @@ -1762,9 +1760,9 @@ Search for an image on [Docker Hub](https://hub.docker.com). - **200** – no error - **500** – server error -## 2.3 Misc +### 2.3 Misc -### Check auth configuration +#### Check auth configuration `POST /auth` @@ -1792,7 +1790,7 @@ Get the default username and email - **204** – no error - **500** – server error -### Display system-wide information +#### Display system-wide information `GET /info` @@ -1861,7 +1859,7 @@ Display system-wide information - **200** – no error - **500** – server error -### Show the docker version information +#### Show the docker version information `GET /version` @@ -1892,7 +1890,7 @@ Show the docker version information - **200** – no error - **500** – server error -### Ping the docker server +#### Ping the docker server `GET /_ping` @@ -1914,7 +1912,7 @@ Ping the docker server - **200** - no error - **500** - server error -### Create a new image from a container's changes +#### Create a new image from a container's changes `POST /commit` @@ -1986,7 +1984,7 @@ Create a new image from a container's changes - **404** – no such container - **500** – server error -### Monitor Docker's events +#### Monitor Docker's events `GET /events` @@ -2028,7 +2026,7 @@ Docker images report the following events: - **200** – no error - **500** – server error -### Get a tarball containing all images in a repository +#### Get a tarball containing all images in a repository `GET /images/(name)/get` @@ -2058,7 +2056,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Get a tarball containing all images +#### Get a tarball containing all images `GET /images/get` @@ -2087,7 +2085,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Load a tarball with a set of images and tags into docker +#### Load a tarball with a set of images and tags into docker `POST /images/load` @@ -2110,7 +2108,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Image tarball format +#### Image tarball format An image tarball contains one directory per image layer (named using its long ID), each containing these files: @@ -2131,7 +2129,7 @@ the root that contains a list of repository and tag names mapped to layer IDs. } ``` -### Exec Create +#### Exec Create `POST /containers/(id or name)/exec` @@ -2177,7 +2175,7 @@ Sets up an exec instance in a running container `id` - **201** – no error - **404** – no such container -### Exec Start +#### Exec Start `POST /exec/(id)/start` @@ -2218,7 +2216,7 @@ interactive session with the `exec` command. Similar to the stream behavior of `POST /containers/(id or name)/attach` API -### Exec Resize +#### Exec Resize `POST /exec/(id)/resize` @@ -2245,7 +2243,7 @@ This API is valid only if `tty` was specified as part of creating and starting t - **201** – no error - **404** – no such exec instance -### Exec Inspect +#### Exec Inspect `GET /exec/(id)/json` @@ -2348,9 +2346,9 @@ Return low-level information about the `exec` command `id`. - **404** – no such exec instance - **500** - server error -# 3. Going further +## 3. Going further -## 3.1 Inside `docker run` +### 3.1 Inside `docker run` As an example, the `docker run` command line makes the following API calls: @@ -2368,7 +2366,7 @@ As an example, the `docker run` command line makes the following API calls: - If in detached mode or only `stdin` is attached, display the container's id. -## 3.2 Hijacking +### 3.2 Hijacking In this version of the API, `/attach`, uses hijacking to transport `stdin`, `stdout`, and `stderr` on the same socket. @@ -2383,7 +2381,7 @@ When Docker daemon detects the `Upgrade` header, it switches its status code from **200 OK** to **101 UPGRADED** and resends the same headers. -## 3.3 CORS Requests +### 3.3 CORS Requests To set cross origin requests to the Engine API please give values to `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, diff --git a/docs/api/v1.21.md b/docs/api/v1.21.md index 7d2c65d6bc77242cd2b5281dc2fae428172d450c..3ab8ac0c9e3c3ac30333d5a8d0824c63bb4da987 100644 --- a/docs/api/v1.21.md +++ b/docs/api/v1.21.md @@ -16,8 +16,6 @@ redirect_from: will be rejected. --> -# Docker Engine API v1.21 - ## 1. Brief introduction - The daemon listens on `unix:///var/run/docker.sock` but you can @@ -28,11 +26,11 @@ redirect_from: - When the client API version is newer than the daemon's, these calls return an HTTP `400 Bad Request` error message. -# 2. Endpoints +## 2. Endpoints -## 2.1 Containers +### 2.1 Containers -### List containers +#### List containers `GET /containers/json` @@ -129,7 +127,7 @@ List containers - **400** – bad parameter - **500** – server error -### Create a container +#### Create a container `POST /containers/create` @@ -347,7 +345,7 @@ Create a container - **409** – conflict - **500** – server error -### Inspect a container +#### Inspect a container `GET /containers/(id or name)/json` @@ -537,7 +535,7 @@ Return low-level information on the container `id` - **404** – no such container - **500** – server error -### List processes running inside a container +#### List processes running inside a container `GET /containers/(id or name)/top` @@ -601,7 +599,7 @@ supported on Windows. - **404** – no such container - **500** – server error -### Get container logs +#### Get container logs `GET /containers/(id or name)/logs` @@ -643,7 +641,7 @@ Get `stdout` and `stderr` logs from the container ``id`` - **404** – no such container - **500** – server error -### Inspect changes on a container's filesystem +#### Inspect changes on a container's filesystem `GET /containers/(id or name)/changes` @@ -685,7 +683,7 @@ Values for `Kind`: - **404** – no such container - **500** – server error -### Export a container +#### Export a container `GET /containers/(id or name)/export` @@ -710,7 +708,7 @@ Export the contents of container `id` - **404** – no such container - **500** – server error -### Get container stats based on resource usage +#### Get container stats based on resource usage `GET /containers/(id or name)/stats` @@ -831,7 +829,7 @@ The precpu_stats is the cpu statistic of last read, which is used for calculatin - **404** – no such container - **500** – server error -### Resize a container TTY +#### Resize a container TTY `POST /containers/(id or name)/resize` @@ -858,7 +856,7 @@ Resize the TTY for container with `id`. The unit is number of characters. You m - **404** – No such container - **500** – Cannot resize container -### Start a container +#### Start a container `POST /containers/(id or name)/start` @@ -883,7 +881,7 @@ Start the container `id` - **404** – no such container - **500** – server error -### Stop a container +#### Stop a container `POST /containers/(id or name)/stop` @@ -908,7 +906,7 @@ Stop the container `id` - **404** – no such container - **500** – server error -### Restart a container +#### Restart a container `POST /containers/(id or name)/restart` @@ -932,7 +930,7 @@ Restart the container `id` - **404** – no such container - **500** – server error -### Kill a container +#### Kill a container `POST /containers/(id or name)/kill` @@ -957,7 +955,7 @@ Kill the container `id` - **404** – no such container - **500** – server error -### Rename a container +#### Rename a container `POST /containers/(id or name)/rename` @@ -982,7 +980,7 @@ Rename the container `id` to a `new_name` - **409** - conflict name already assigned - **500** – server error -### Pause a container +#### Pause a container `POST /containers/(id or name)/pause` @@ -1002,7 +1000,7 @@ Pause the container `id` - **404** – no such container - **500** – server error -### Unpause a container +#### Unpause a container `POST /containers/(id or name)/unpause` @@ -1022,7 +1020,7 @@ Unpause the container `id` - **404** – no such container - **500** – server error -### Attach to a container +#### Attach to a container `POST /containers/(id or name)/attach` @@ -1107,7 +1105,7 @@ The simplest way to implement the Attach protocol is the following: 4. Read the extracted size and output it on the correct output. 5. Goto 1. -### Attach to a container (websocket) +#### Attach to a container (websocket) `GET /containers/(id or name)/attach/ws` @@ -1144,7 +1142,7 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet - **404** – no such container - **500** – server error -### Wait a container +#### Wait a container `POST /containers/(id or name)/wait` @@ -1167,7 +1165,7 @@ Block until container `id` stops, then returns the exit code - **404** – no such container - **500** – server error -### Remove a container +#### Remove a container `DELETE /containers/(id or name)` @@ -1196,7 +1194,7 @@ Remove the container `id` from the filesystem - **409** – conflict - **500** – server error -### Copy files or folders from a container +#### Copy files or folders from a container `POST /containers/(id or name)/copy` @@ -1228,14 +1226,14 @@ Copy files or folders of container `id` - **404** – no such container - **500** – server error -### Retrieving information about files and folders in a container +#### Retrieving information about files and folders in a container `HEAD /containers/(id or name)/archive` See the description of the `X-Docker-Container-Path-Stat` header in the following section. -### Get an archive of a filesystem resource in a container +#### Get an archive of a filesystem resource in a container `GET /containers/(id or name)/archive` @@ -1300,7 +1298,7 @@ desired. - no such file or directory (**path** does not exist) - **500** - server error -### Extract an archive of files or folders to a directory in a container +#### Extract an archive of files or folders to a directory in a container `PUT /containers/(id or name)/archive` @@ -1348,9 +1346,9 @@ Upload a tar archive to be extracted to a path in the filesystem of container - no such file or directory (**path** resource does not exist) - **500** – server error -## 2.2 Images +### 2.2 Images -### List Images +#### List Images `GET /images/json` @@ -1441,7 +1439,7 @@ references on the command line. - `label=key` or `label="key=value"` of an image label - **filter** - only return images with the specified name -### Build image from a Dockerfile +#### Build image from a Dockerfile `POST /build` @@ -1545,7 +1543,7 @@ or being killed. - **200** – no error - **500** – server error -### Create an image +#### Create an image `POST /images/create` @@ -1593,7 +1591,7 @@ a base64-encoded AuthConfig object. -### Inspect an image +#### Inspect an image `GET /images/(name)/json` @@ -1704,7 +1702,7 @@ Return low-level information on the image `name` - **404** – no such image - **500** – server error -### Get the history of an image +#### Get the history of an image `GET /images/(name)/history` @@ -1758,7 +1756,7 @@ Return the history of the image `name` - **404** – no such image - **500** – server error -### Push an image on the registry +#### Push an image on the registry `POST /images/(name)/push` @@ -1801,7 +1799,7 @@ then be used in the URL. This duplicates the command line's flow. - **404** – no such image - **500** – server error -### Tag an image into a repository +#### Tag an image into a repository `POST /images/(name)/tag` @@ -1829,7 +1827,7 @@ Tag the image `name` into a repository - **409** – conflict - **500** – server error -### Remove an image +#### Remove an image `DELETE /images/(name)` @@ -1862,7 +1860,7 @@ Remove the image `name` from the filesystem - **409** – conflict - **500** – server error -### Search images +#### Search images `GET /images/search` @@ -1915,9 +1913,9 @@ Search for an image on [Docker Hub](https://hub.docker.com). - **200** – no error - **500** – server error -## 2.3 Misc +### 2.3 Misc -### Check auth configuration +#### Check auth configuration `POST /auth` @@ -1945,7 +1943,7 @@ Get the default username and email - **204** – no error - **500** – server error -### Display system-wide information +#### Display system-wide information `GET /info` @@ -2016,7 +2014,7 @@ Display system-wide information - **200** – no error - **500** – server error -### Show the docker version information +#### Show the docker version information `GET /version` @@ -2047,7 +2045,7 @@ Show the docker version information - **200** – no error - **500** – server error -### Ping the docker server +#### Ping the docker server `GET /_ping` @@ -2069,7 +2067,7 @@ Ping the docker server - **200** - no error - **500** - server error -### Create a new image from a container's changes +#### Create a new image from a container's changes `POST /commit` @@ -2141,7 +2139,7 @@ Create a new image from a container's changes - **404** – no such container - **500** – server error -### Monitor Docker's events +#### Monitor Docker's events `GET /events` @@ -2184,7 +2182,7 @@ Docker images report the following events: - **200** – no error - **500** – server error -### Get a tarball containing all images in a repository +#### Get a tarball containing all images in a repository `GET /images/(name)/get` @@ -2214,7 +2212,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Get a tarball containing all images +#### Get a tarball containing all images `GET /images/get` @@ -2243,7 +2241,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Load a tarball with a set of images and tags into docker +#### Load a tarball with a set of images and tags into docker `POST /images/load` @@ -2266,7 +2264,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Image tarball format +#### Image tarball format An image tarball contains one directory per image layer (named using its long ID), each containing these files: @@ -2287,7 +2285,7 @@ the root that contains a list of repository and tag names mapped to layer IDs. } ``` -### Exec Create +#### Exec Create `POST /containers/(id or name)/exec` @@ -2337,7 +2335,7 @@ Sets up an exec instance in a running container `id` - **409** - container is paused - **500** - server error -### Exec Start +#### Exec Start `POST /exec/(id)/start` @@ -2379,7 +2377,7 @@ interactive session with the `exec` command. Similar to the stream behavior of `POST /containers/(id or name)/attach` API -### Exec Resize +#### Exec Resize `POST /exec/(id)/resize` @@ -2406,7 +2404,7 @@ This API is valid only if `tty` was specified as part of creating and starting t - **201** – no error - **404** – no such exec instance -### Exec Inspect +#### Exec Inspect `GET /exec/(id)/json` @@ -2532,9 +2530,9 @@ Return low-level information about the `exec` command `id`. - **404** – no such exec instance - **500** - server error -## 2.4 Volumes +### 2.4 Volumes -### List volumes +#### List volumes `GET /volumes` @@ -2566,7 +2564,7 @@ Return low-level information about the `exec` command `id`. - **200** - no error - **500** - server error -### Create a volume +#### Create a volume `POST /volumes/create` @@ -2604,7 +2602,7 @@ Create a volume - **DriverOpts** - A mapping of driver options and values. These options are passed directly to the driver and are driver specific. -### Inspect a volume +#### Inspect a volume `GET /volumes/(name)` @@ -2631,7 +2629,7 @@ Return low-level information on the volume `name` - **404** - no such volume - **500** - server error -### Remove a volume +#### Remove a volume `DELETE /volumes/(name)` @@ -2652,9 +2650,9 @@ Instruct the driver to remove the volume (`name`). - **409** - volume is in use and cannot be removed - **500** - server error -## 2.5 Networks +### 2.5 Networks -### List networks +#### List networks `GET /networks` @@ -2735,7 +2733,7 @@ Content-Type: application/json - **200** - no error - **500** - server error -### Inspect network +#### Inspect network `GET /networks/` @@ -2786,7 +2784,7 @@ Content-Type: application/json - **200** - no error - **404** - network not found -### Create a network +#### Create a network `POST /networks/create` @@ -2844,7 +2842,7 @@ Content-Type: application/json `{"Subnet": , "IPRange": , "Gateway": , "AuxAddress": }` - **Options** - Network specific options to be used by the drivers -### Connect a container to a network +#### Connect a container to a network `POST /networks/(id)/connect` @@ -2875,7 +2873,7 @@ Content-Type: application/json - **container** - container-id/name to be connected to the network -### Disconnect a container from a network +#### Disconnect a container from a network `POST /networks/(id)/disconnect` @@ -2906,7 +2904,7 @@ Content-Type: application/json - **Container** - container-id/name to be disconnected from a network -### Remove a network +#### Remove a network `DELETE /networks/(id)` @@ -2926,9 +2924,9 @@ Instruct the driver to remove the network (`id`). - **404** - no such network - **500** - server error -# 3. Going further +## 3. Going further -## 3.1 Inside `docker run` +### 3.1 Inside `docker run` As an example, the `docker run` command line makes the following API calls: @@ -2946,7 +2944,7 @@ As an example, the `docker run` command line makes the following API calls: - If in detached mode or only `stdin` is attached, display the container's id. -## 3.2 Hijacking +### 3.2 Hijacking In this version of the API, `/attach`, uses hijacking to transport `stdin`, `stdout`, and `stderr` on the same socket. @@ -2961,7 +2959,7 @@ When Docker daemon detects the `Upgrade` header, it switches its status code from **200 OK** to **101 UPGRADED** and resends the same headers. -## 3.3 CORS Requests +### 3.3 CORS Requests To set cross origin requests to the Engine API please give values to `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, diff --git a/docs/api/v1.22.md b/docs/api/v1.22.md index 66391eafa3477c4af3b2cf1d45a39da0f2f3499f..943224cabd3fc17e1e4411144af31cdacdb46cd2 100644 --- a/docs/api/v1.22.md +++ b/docs/api/v1.22.md @@ -16,9 +16,7 @@ redirect_from: will be rejected. --> -# Docker Engine API v1.22 - -# 1. Brief introduction +## 1. Brief introduction - The daemon listens on `unix:///var/run/docker.sock` but you can [Bind Docker to another host/port or a Unix socket](../commandline/dockerd.md#bind-docker-to-another-host-port-or-a-unix-socket). @@ -26,11 +24,11 @@ redirect_from: or `pull`, the HTTP connection is hijacked to transport `stdout`, `stdin` and `stderr`. -# 2. Endpoints +## 2. Endpoints -## 2.1 Containers +### 2.1 Containers -### List containers +#### List containers `GET /containers/json` @@ -212,7 +210,7 @@ List containers - **400** – bad parameter - **500** – server error -### Create a container +#### Create a container `POST /containers/create` @@ -460,7 +458,7 @@ Create a container - **409** – conflict - **500** – server error -### Inspect a container +#### Inspect a container `GET /containers/(id or name)/json` @@ -663,7 +661,7 @@ Return low-level information on the container `id` - **404** – no such container - **500** – server error -### List processes running inside a container +#### List processes running inside a container `GET /containers/(id or name)/top` @@ -727,7 +725,7 @@ supported on Windows. - **404** – no such container - **500** – server error -### Get container logs +#### Get container logs `GET /containers/(id or name)/logs` @@ -769,7 +767,7 @@ Get `stdout` and `stderr` logs from the container ``id`` - **404** – no such container - **500** – server error -### Inspect changes on a container's filesystem +#### Inspect changes on a container's filesystem `GET /containers/(id or name)/changes` @@ -811,7 +809,7 @@ Values for `Kind`: - **404** – no such container - **500** – server error -### Export a container +#### Export a container `GET /containers/(id or name)/export` @@ -836,7 +834,7 @@ Export the contents of container `id` - **404** – no such container - **500** – server error -### Get container stats based on resource usage +#### Get container stats based on resource usage `GET /containers/(id or name)/stats` @@ -957,7 +955,7 @@ The precpu_stats is the cpu statistic of last read, which is used for calculatin - **404** – no such container - **500** – server error -### Resize a container TTY +#### Resize a container TTY `POST /containers/(id or name)/resize` @@ -984,7 +982,7 @@ Resize the TTY for container with `id`. The unit is number of characters. You m - **404** – No such container - **500** – Cannot resize container -### Start a container +#### Start a container `POST /containers/(id or name)/start` @@ -1015,7 +1013,7 @@ Start the container `id` - **404** – no such container - **500** – server error -### Stop a container +#### Stop a container `POST /containers/(id or name)/stop` @@ -1040,7 +1038,7 @@ Stop the container `id` - **404** – no such container - **500** – server error -### Restart a container +#### Restart a container `POST /containers/(id or name)/restart` @@ -1064,7 +1062,7 @@ Restart the container `id` - **404** – no such container - **500** – server error -### Kill a container +#### Kill a container `POST /containers/(id or name)/kill` @@ -1089,7 +1087,7 @@ Kill the container `id` - **404** – no such container - **500** – server error -### Update a container +#### Update a container `POST /containers/(id or name)/update` @@ -1129,7 +1127,7 @@ Update resource configs of one or more containers. - **404** – no such container - **500** – server error -### Rename a container +#### Rename a container `POST /containers/(id or name)/rename` @@ -1154,7 +1152,7 @@ Rename the container `id` to a `new_name` - **409** - conflict name already assigned - **500** – server error -### Pause a container +#### Pause a container `POST /containers/(id or name)/pause` @@ -1174,7 +1172,7 @@ Pause the container `id` - **404** – no such container - **500** – server error -### Unpause a container +#### Unpause a container `POST /containers/(id or name)/unpause` @@ -1194,7 +1192,7 @@ Unpause the container `id` - **404** – no such container - **500** – server error -### Attach to a container +#### Attach to a container `POST /containers/(id or name)/attach` @@ -1283,7 +1281,7 @@ The simplest way to implement the Attach protocol is the following: 4. Read the extracted size and output it on the correct output. 5. Goto 1. -### Attach to a container (websocket) +#### Attach to a container (websocket) `GET /containers/(id or name)/attach/ws` @@ -1323,7 +1321,7 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet - **404** – no such container - **500** – server error -### Wait a container +#### Wait a container `POST /containers/(id or name)/wait` @@ -1346,7 +1344,7 @@ Block until container `id` stops, then returns the exit code - **404** – no such container - **500** – server error -### Remove a container +#### Remove a container `DELETE /containers/(id or name)` @@ -1375,7 +1373,7 @@ Remove the container `id` from the filesystem - **409** – conflict - **500** – server error -### Copy files or folders from a container +#### Copy files or folders from a container `POST /containers/(id or name)/copy` @@ -1407,14 +1405,14 @@ Copy files or folders of container `id` - **404** – no such container - **500** – server error -### Retrieving information about files and folders in a container +#### Retrieving information about files and folders in a container `HEAD /containers/(id or name)/archive` See the description of the `X-Docker-Container-Path-Stat` header in the following section. -### Get an archive of a filesystem resource in a container +#### Get an archive of a filesystem resource in a container `GET /containers/(id or name)/archive` @@ -1479,7 +1477,7 @@ desired. - no such file or directory (**path** does not exist) - **500** - server error -### Extract an archive of files or folders to a directory in a container +#### Extract an archive of files or folders to a directory in a container `PUT /containers/(id or name)/archive` @@ -1527,9 +1525,9 @@ Upload a tar archive to be extracted to a path in the filesystem of container - no such file or directory (**path** resource does not exist) - **500** – server error -## 2.2 Images +### 2.2 Images -### List Images +#### List Images `GET /images/json` @@ -1620,7 +1618,7 @@ references on the command line. - `label=key` or `label="key=value"` of an image label - **filter** - only return images with the specified name -### Build image from a Dockerfile +#### Build image from a Dockerfile `POST /build` @@ -1725,7 +1723,7 @@ or being killed. - **200** – no error - **500** – server error -### Create an image +#### Create an image `POST /images/create` @@ -1791,7 +1789,7 @@ a base64-encoded AuthConfig object. -### Inspect an image +#### Inspect an image `GET /images/(name)/json` @@ -1902,7 +1900,7 @@ Return low-level information on the image `name` - **404** – no such image - **500** – server error -### Get the history of an image +#### Get the history of an image `GET /images/(name)/history` @@ -1956,7 +1954,7 @@ Return the history of the image `name` - **404** – no such image - **500** – server error -### Push an image on the registry +#### Push an image on the registry `POST /images/(name)/push` @@ -2018,7 +2016,7 @@ The push is cancelled if the HTTP connection is closed. - **404** – no such image - **500** – server error -### Tag an image into a repository +#### Tag an image into a repository `POST /images/(name)/tag` @@ -2046,7 +2044,7 @@ Tag the image `name` into a repository - **409** – conflict - **500** – server error -### Remove an image +#### Remove an image `DELETE /images/(name)` @@ -2079,7 +2077,7 @@ Remove the image `name` from the filesystem - **409** – conflict - **500** – server error -### Search images +#### Search images `GET /images/search` @@ -2132,9 +2130,9 @@ Search for an image on [Docker Hub](https://hub.docker.com). - **200** – no error - **500** – server error -## 2.3 Misc +### 2.3 Misc -### Check auth configuration +#### Check auth configuration `POST /auth` @@ -2162,7 +2160,7 @@ Get the default username and email - **204** – no error - **500** – server error -### Display system-wide information +#### Display system-wide information `GET /info` @@ -2249,7 +2247,7 @@ Display system-wide information - **200** – no error - **500** – server error -### Show the docker version information +#### Show the docker version information `GET /version` @@ -2281,7 +2279,7 @@ Show the docker version information - **200** – no error - **500** – server error -### Ping the docker server +#### Ping the docker server `GET /_ping` @@ -2303,7 +2301,7 @@ Ping the docker server - **200** - no error - **500** - server error -### Create a new image from a container's changes +#### Create a new image from a container's changes `POST /commit` @@ -2375,7 +2373,7 @@ Create a new image from a container's changes - **404** – no such container - **500** – server error -### Monitor Docker's events +#### Monitor Docker's events `GET /events` @@ -2575,7 +2573,7 @@ Docker networks report the following events: - **200** – no error - **500** – server error -### Get a tarball containing all images in a repository +#### Get a tarball containing all images in a repository `GET /images/(name)/get` @@ -2605,7 +2603,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Get a tarball containing all images +#### Get a tarball containing all images `GET /images/get` @@ -2634,7 +2632,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Load a tarball with a set of images and tags into docker +#### Load a tarball with a set of images and tags into docker `POST /images/load` @@ -2657,7 +2655,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Image tarball format +#### Image tarball format An image tarball contains one directory per image layer (named using its long ID), each containing these files: @@ -2678,7 +2676,7 @@ the root that contains a list of repository and tag names mapped to layer IDs. } ``` -### Exec Create +#### Exec Create `POST /containers/(id or name)/exec` @@ -2732,7 +2730,7 @@ Sets up an exec instance in a running container `id` - **409** - container is paused - **500** - server error -### Exec Start +#### Exec Start `POST /exec/(id)/start` @@ -2774,7 +2772,7 @@ interactive session with the `exec` command. Similar to the stream behavior of `POST /containers/(id or name)/attach` API -### Exec Resize +#### Exec Resize `POST /exec/(id)/resize` @@ -2801,7 +2799,7 @@ This API is valid only if `tty` was specified as part of creating and starting t - **201** – no error - **404** – no such exec instance -### Exec Inspect +#### Exec Inspect `GET /exec/(id)/json` @@ -2844,9 +2842,9 @@ Return low-level information about the `exec` command `id`. - **404** – no such exec instance - **500** - server error -## 2.4 Volumes +### 2.4 Volumes -### List volumes +#### List volumes `GET /volumes` @@ -2879,7 +2877,7 @@ Return low-level information about the `exec` command `id`. - **200** - no error - **500** - server error -### Create a volume +#### Create a volume `POST /volumes/create` @@ -2917,7 +2915,7 @@ Create a volume - **DriverOpts** - A mapping of driver options and values. These options are passed directly to the driver and are driver specific. -### Inspect a volume +#### Inspect a volume `GET /volumes/(name)` @@ -2944,7 +2942,7 @@ Return low-level information on the volume `name` - **404** - no such volume - **500** - server error -### Remove a volume +#### Remove a volume `DELETE /volumes/(name)` @@ -2965,9 +2963,9 @@ Instruct the driver to remove the volume (`name`). - **409** - volume is in use and cannot be removed - **500** - server error -## 2.5 Networks +### 2.5 Networks -### List networks +#### List networks `GET /networks` @@ -3051,7 +3049,7 @@ Content-Type: application/json - **200** - no error - **500** - server error -### Inspect network +#### Inspect network `GET /networks/` @@ -3107,7 +3105,7 @@ Content-Type: application/json - **200** - no error - **404** - network not found -### Create a network +#### Create a network `POST /networks/create` @@ -3174,7 +3172,7 @@ Content-Type: application/json - **Options** - Driver-specific options, specified as a map: `{"option":"value" [,"option2":"value2"]}` - **Options** - Network specific options to be used by the drivers -### Connect a container to a network +#### Connect a container to a network `POST /networks/(id)/connect` @@ -3211,7 +3209,7 @@ Content-Type: application/json - **container** - container-id/name to be connected to the network -### Disconnect a container from a network +#### Disconnect a container from a network `POST /networks/(id)/disconnect` @@ -3244,7 +3242,7 @@ Content-Type: application/json - **Container** - container-id/name to be disconnected from a network - **Force** - Force the container to disconnect from a network -### Remove a network +#### Remove a network `DELETE /networks/(id)` @@ -3264,9 +3262,9 @@ Instruct the driver to remove the network (`id`). - **404** - no such network - **500** - server error -# 3. Going further +## 3. Going further -## 3.1 Inside `docker run` +### 3.1 Inside `docker run` As an example, the `docker run` command line makes the following API calls: @@ -3284,7 +3282,7 @@ As an example, the `docker run` command line makes the following API calls: - If in detached mode or only `stdin` is attached, display the container's id. -## 3.2 Hijacking +### 3.2 Hijacking In this version of the API, `/attach`, uses hijacking to transport `stdin`, `stdout`, and `stderr` on the same socket. @@ -3299,7 +3297,7 @@ When Docker daemon detects the `Upgrade` header, it switches its status code from **200 OK** to **101 UPGRADED** and resends the same headers. -## 3.3 CORS Requests +### 3.3 CORS Requests To set cross origin requests to the Engine API please give values to `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, diff --git a/docs/api/v1.23.md b/docs/api/v1.23.md index f0a560c7772007f77aab0822b3e56a81aa1dcb8f..d8c39b39e1ec521191b3003c01e4fd4ad6704c32 100644 --- a/docs/api/v1.23.md +++ b/docs/api/v1.23.md @@ -16,8 +16,6 @@ redirect_from: will be rejected. --> -# Docker Engine API v1.23 - ## 1. Brief introduction - The daemon listens on `unix:///var/run/docker.sock` but you can @@ -28,11 +26,11 @@ redirect_from: - When the client API version is newer than the daemon's, these calls return an HTTP `400 Bad Request` error message. -# 2. Endpoints +## 2. Endpoints -## 2.1 Containers +### 2.1 Containers -### List containers +#### List containers `GET /containers/json` @@ -236,7 +234,7 @@ List containers - **400** – bad parameter - **500** – server error -### Create a container +#### Create a container `POST /containers/create` @@ -488,7 +486,7 @@ Create a container - **409** – conflict - **500** – server error -### Inspect a container +#### Inspect a container `GET /containers/(id or name)/json` @@ -691,7 +689,7 @@ Return low-level information on the container `id` - **404** – no such container - **500** – server error -### List processes running inside a container +#### List processes running inside a container `GET /containers/(id or name)/top` @@ -755,7 +753,7 @@ supported on Windows. - **404** – no such container - **500** – server error -### Get container logs +#### Get container logs `GET /containers/(id or name)/logs` @@ -797,7 +795,7 @@ Get `stdout` and `stderr` logs from the container ``id`` - **404** – no such container - **500** – server error -### Inspect changes on a container's filesystem +#### Inspect changes on a container's filesystem `GET /containers/(id or name)/changes` @@ -839,7 +837,7 @@ Values for `Kind`: - **404** – no such container - **500** – server error -### Export a container +#### Export a container `GET /containers/(id or name)/export` @@ -864,7 +862,7 @@ Export the contents of container `id` - **404** – no such container - **500** – server error -### Get container stats based on resource usage +#### Get container stats based on resource usage `GET /containers/(id or name)/stats` @@ -988,7 +986,7 @@ The precpu_stats is the cpu statistic of last read, which is used for calculatin - **404** – no such container - **500** – server error -### Resize a container TTY +#### Resize a container TTY `POST /containers/(id or name)/resize` @@ -1015,7 +1013,7 @@ Resize the TTY for container with `id`. The unit is number of characters. You m - **404** – No such container - **500** – Cannot resize container -### Start a container +#### Start a container `POST /containers/(id or name)/start` @@ -1046,7 +1044,7 @@ Start the container `id` - **404** – no such container - **500** – server error -### Stop a container +#### Stop a container `POST /containers/(id or name)/stop` @@ -1071,7 +1069,7 @@ Stop the container `id` - **404** – no such container - **500** – server error -### Restart a container +#### Restart a container `POST /containers/(id or name)/restart` @@ -1095,7 +1093,7 @@ Restart the container `id` - **404** – no such container - **500** – server error -### Kill a container +#### Kill a container `POST /containers/(id or name)/kill` @@ -1120,7 +1118,7 @@ Kill the container `id` - **404** – no such container - **500** – server error -### Update a container +#### Update a container `POST /containers/(id or name)/update` @@ -1164,7 +1162,7 @@ Update configuration of one or more containers. - **404** – no such container - **500** – server error -### Rename a container +#### Rename a container `POST /containers/(id or name)/rename` @@ -1189,7 +1187,7 @@ Rename the container `id` to a `new_name` - **409** - conflict name already assigned - **500** – server error -### Pause a container +#### Pause a container `POST /containers/(id or name)/pause` @@ -1209,7 +1207,7 @@ Pause the container `id` - **404** – no such container - **500** – server error -### Unpause a container +#### Unpause a container `POST /containers/(id or name)/unpause` @@ -1229,7 +1227,7 @@ Unpause the container `id` - **404** – no such container - **500** – server error -### Attach to a container +#### Attach to a container `POST /containers/(id or name)/attach` @@ -1318,7 +1316,7 @@ The simplest way to implement the Attach protocol is the following: 4. Read the extracted size and output it on the correct output. 5. Goto 1. -### Attach to a container (websocket) +#### Attach to a container (websocket) `GET /containers/(id or name)/attach/ws` @@ -1358,7 +1356,7 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet - **404** – no such container - **500** – server error -### Wait a container +#### Wait a container `POST /containers/(id or name)/wait` @@ -1381,7 +1379,7 @@ Block until container `id` stops, then returns the exit code - **404** – no such container - **500** – server error -### Remove a container +#### Remove a container `DELETE /containers/(id or name)` @@ -1410,7 +1408,7 @@ Remove the container `id` from the filesystem - **409** – conflict - **500** – server error -### Copy files or folders from a container +#### Copy files or folders from a container `POST /containers/(id or name)/copy` @@ -1442,14 +1440,14 @@ Copy files or folders of container `id` - **404** – no such container - **500** – server error -### Retrieving information about files and folders in a container +#### Retrieving information about files and folders in a container `HEAD /containers/(id or name)/archive` See the description of the `X-Docker-Container-Path-Stat` header in the following section. -### Get an archive of a filesystem resource in a container +#### Get an archive of a filesystem resource in a container `GET /containers/(id or name)/archive` @@ -1514,7 +1512,7 @@ desired. - no such file or directory (**path** does not exist) - **500** - server error -### Extract an archive of files or folders to a directory in a container +#### Extract an archive of files or folders to a directory in a container `PUT /containers/(id or name)/archive` @@ -1562,9 +1560,9 @@ Upload a tar archive to be extracted to a path in the filesystem of container - no such file or directory (**path** resource does not exist) - **500** – server error -## 2.2 Images +### 2.2 Images -### List Images +#### List Images `GET /images/json` @@ -1655,7 +1653,7 @@ references on the command line. - `label=key` or `label="key=value"` of an image label - **filter** - only return images with the specified name -### Build image from a Dockerfile +#### Build image from a Dockerfile `POST /build` @@ -1761,7 +1759,7 @@ or being killed. - **200** – no error - **500** – server error -### Create an image +#### Create an image `POST /images/create` @@ -1827,7 +1825,7 @@ a base64-encoded AuthConfig object. -### Inspect an image +#### Inspect an image `GET /images/(name)/json` @@ -1945,7 +1943,7 @@ Return low-level information on the image `name` - **404** – no such image - **500** – server error -### Get the history of an image +#### Get the history of an image `GET /images/(name)/history` @@ -1999,7 +1997,7 @@ Return the history of the image `name` - **404** – no such image - **500** – server error -### Push an image on the registry +#### Push an image on the registry `POST /images/(name)/push` @@ -2061,7 +2059,7 @@ The push is cancelled if the HTTP connection is closed. - **404** – no such image - **500** – server error -### Tag an image into a repository +#### Tag an image into a repository `POST /images/(name)/tag` @@ -2089,7 +2087,7 @@ Tag the image `name` into a repository - **409** – conflict - **500** – server error -### Remove an image +#### Remove an image `DELETE /images/(name)` @@ -2122,7 +2120,7 @@ Remove the image `name` from the filesystem - **409** – conflict - **500** – server error -### Search images +#### Search images `GET /images/search` @@ -2175,9 +2173,9 @@ Search for an image on [Docker Hub](https://hub.docker.com). - **200** – no error - **500** – server error -## 2.3 Misc +### 2.3 Misc -### Check auth configuration +#### Check auth configuration `POST /auth` @@ -2210,7 +2208,7 @@ if available, for accessing the registry without password. - **204** – no error - **500** – server error -### Display system-wide information +#### Display system-wide information `GET /info` @@ -2299,7 +2297,7 @@ Display system-wide information - **200** – no error - **500** – server error -### Show the docker version information +#### Show the docker version information `GET /version` @@ -2331,7 +2329,7 @@ Show the docker version information - **200** – no error - **500** – server error -### Ping the docker server +#### Ping the docker server `GET /_ping` @@ -2353,7 +2351,7 @@ Ping the docker server - **200** - no error - **500** - server error -### Create a new image from a container's changes +#### Create a new image from a container's changes `POST /commit` @@ -2425,7 +2423,7 @@ Create a new image from a container's changes - **404** – no such container - **500** – server error -### Monitor Docker's events +#### Monitor Docker's events `GET /events` @@ -2625,7 +2623,7 @@ Docker networks report the following events: - **200** – no error - **500** – server error -### Get a tarball containing all images in a repository +#### Get a tarball containing all images in a repository `GET /images/(name)/get` @@ -2655,7 +2653,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Get a tarball containing all images +#### Get a tarball containing all images `GET /images/get` @@ -2684,7 +2682,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Load a tarball with a set of images and tags into docker +#### Load a tarball with a set of images and tags into docker `POST /images/load` @@ -2733,7 +2731,7 @@ action completes. - **200** – no error - **500** – server error -### Image tarball format +#### Image tarball format An image tarball contains one directory per image layer (named using its long ID), each containing these files: @@ -2754,7 +2752,7 @@ the root that contains a list of repository and tag names mapped to layer IDs. } ``` -### Exec Create +#### Exec Create `POST /containers/(id or name)/exec` @@ -2808,7 +2806,7 @@ Sets up an exec instance in a running container `id` - **409** - container is paused - **500** - server error -### Exec Start +#### Exec Start `POST /exec/(id)/start` @@ -2850,7 +2848,7 @@ interactive session with the `exec` command. Similar to the stream behavior of `POST /containers/(id or name)/attach` API -### Exec Resize +#### Exec Resize `POST /exec/(id)/resize` @@ -2877,7 +2875,7 @@ This API is valid only if `tty` was specified as part of creating and starting t - **201** – no error - **404** – no such exec instance -### Exec Inspect +#### Exec Inspect `GET /exec/(id)/json` @@ -2920,9 +2918,9 @@ Return low-level information about the `exec` command `id`. - **404** – no such exec instance - **500** - server error -## 2.4 Volumes +### 2.4 Volumes -### List volumes +#### List volumes `GET /volumes` @@ -2955,7 +2953,7 @@ Return low-level information about the `exec` command `id`. - **200** - no error - **500** - server error -### Create a volume +#### Create a volume `POST /volumes/create` @@ -3002,7 +3000,7 @@ Create a volume passed directly to the driver and are driver specific. - **Labels** - Labels to set on the volume, specified as a map: `{"key":"value","key2":"value2"}` -### Inspect a volume +#### Inspect a volume `GET /volumes/(name)` @@ -3033,7 +3031,7 @@ Return low-level information on the volume `name` - **404** - no such volume - **500** - server error -### Remove a volume +#### Remove a volume `DELETE /volumes/(name)` @@ -3054,9 +3052,9 @@ Instruct the driver to remove the volume (`name`). - **409** - volume is in use and cannot be removed - **500** - server error -## 3.5 Networks +### 3.5 Networks -### List networks +#### List networks `GET /networks` @@ -3146,7 +3144,7 @@ Content-Type: application/json - **200** - no error - **500** - server error -### Inspect network +#### Inspect network `GET /networks/` @@ -3208,7 +3206,7 @@ Content-Type: application/json - **200** - no error - **404** - network not found -### Create a network +#### Create a network `POST /networks/create` @@ -3291,7 +3289,7 @@ Content-Type: application/json - **Options** - Network specific options to be used by the drivers - **Labels** - Labels to set on the network, specified as a map: `{"key":"value" [,"key2":"value2"]}` -### Connect a container to a network +#### Connect a container to a network `POST /networks/(id)/connect` @@ -3328,7 +3326,7 @@ Content-Type: application/json - **container** - container-id/name to be connected to the network -### Disconnect a container from a network +#### Disconnect a container from a network `POST /networks/(id)/disconnect` @@ -3361,7 +3359,7 @@ Content-Type: application/json - **Container** - container-id/name to be disconnected from a network - **Force** - Force the container to disconnect from a network -### Remove a network +#### Remove a network `DELETE /networks/(id)` @@ -3381,9 +3379,9 @@ Instruct the driver to remove the network (`id`). - **404** - no such network - **500** - server error -# 3. Going further +## 3. Going further -## 3.1 Inside `docker run` +### 3.1 Inside `docker run` As an example, the `docker run` command line makes the following API calls: @@ -3401,7 +3399,7 @@ As an example, the `docker run` command line makes the following API calls: - If in detached mode or only `stdin` is attached, display the container's id. -## 3.2 Hijacking +### 3.2 Hijacking In this version of the API, `/attach`, uses hijacking to transport `stdin`, `stdout`, and `stderr` on the same socket. @@ -3416,7 +3414,7 @@ When Docker daemon detects the `Upgrade` header, it switches its status code from **200 OK** to **101 UPGRADED** and resends the same headers. -## 3.3 CORS Requests +### 3.3 CORS Requests To set cross origin requests to the Engine API please give values to `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, diff --git a/docs/api/v1.24.md b/docs/api/v1.24.md index 475fb7d3391a6cf02afe44c70958841edaaedfa5..056ca417c16b46a2d81097fe3f706af39747c328 100644 --- a/docs/api/v1.24.md +++ b/docs/api/v1.24.md @@ -16,9 +16,7 @@ redirect_from: will be rejected. --> -# Docker Engine API v1.24 - -# 1. Brief introduction +## 1. Brief introduction - The daemon listens on `unix:///var/run/docker.sock` but you can [Bind Docker to another host/port or a Unix socket](../commandline/dockerd.md#bind-docker-to-another-host-port-or-a-unix-socket). @@ -26,7 +24,7 @@ redirect_from: or `pull`, the HTTP connection is hijacked to transport `stdout`, `stdin` and `stderr`. -# 2. Errors +## 2. Errors The Engine API uses standard HTTP status codes to indicate the success or failure of the API call. The body of the response will be JSON in the following format: @@ -36,11 +34,11 @@ The Engine API uses standard HTTP status codes to indicate the success or failur The status codes that are returned for each endpoint are specified in the endpoint documentation below. -# 3. Endpoints +## 3. Endpoints -## 3.1 Containers +### 3.1 Containers -### List containers +#### List containers `GET /containers/json` @@ -245,7 +243,7 @@ List containers - **400** – bad parameter - **500** – server error -### Create a container +#### Create a container `POST /containers/create` @@ -511,7 +509,7 @@ Create a container - **409** – conflict - **500** – server error -### Inspect a container +#### Inspect a container `GET /containers/(id or name)/json` @@ -721,7 +719,7 @@ Return low-level information on the container `id` - **404** – no such container - **500** – server error -### List processes running inside a container +#### List processes running inside a container `GET /containers/(id or name)/top` @@ -785,7 +783,7 @@ supported on Windows. - **404** – no such container - **500** – server error -### Get container logs +#### Get container logs `GET /containers/(id or name)/logs` @@ -828,7 +826,7 @@ Get `stdout` and `stderr` logs from the container ``id`` - **404** – no such container - **500** – server error -### Inspect changes on a container's filesystem +#### Inspect changes on a container's filesystem `GET /containers/(id or name)/changes` @@ -870,7 +868,7 @@ Values for `Kind`: - **404** – no such container - **500** – server error -### Export a container +#### Export a container `GET /containers/(id or name)/export` @@ -895,7 +893,7 @@ Export the contents of container `id` - **404** – no such container - **500** – server error -### Get container stats based on resource usage +#### Get container stats based on resource usage `GET /containers/(id or name)/stats` @@ -1019,7 +1017,7 @@ The precpu_stats is the cpu statistic of last read, which is used for calculatin - **404** – no such container - **500** – server error -### Resize a container TTY +#### Resize a container TTY `POST /containers/(id or name)/resize` @@ -1046,7 +1044,7 @@ Resize the TTY for container with `id`. The unit is number of characters. You m - **404** – No such container - **500** – Cannot resize container -### Start a container +#### Start a container `POST /containers/(id or name)/start` @@ -1073,7 +1071,7 @@ Start the container `id` - **404** – no such container - **500** – server error -### Stop a container +#### Stop a container `POST /containers/(id or name)/stop` @@ -1098,7 +1096,7 @@ Stop the container `id` - **404** – no such container - **500** – server error -### Restart a container +#### Restart a container `POST /containers/(id or name)/restart` @@ -1122,7 +1120,7 @@ Restart the container `id` - **404** – no such container - **500** – server error -### Kill a container +#### Kill a container `POST /containers/(id or name)/kill` @@ -1147,7 +1145,7 @@ Kill the container `id` - **404** – no such container - **500** – server error -### Update a container +#### Update a container `POST /containers/(id or name)/update` @@ -1191,7 +1189,7 @@ Update configuration of one or more containers. - **404** – no such container - **500** – server error -### Rename a container +#### Rename a container `POST /containers/(id or name)/rename` @@ -1216,7 +1214,7 @@ Rename the container `id` to a `new_name` - **409** - conflict name already assigned - **500** – server error -### Pause a container +#### Pause a container `POST /containers/(id or name)/pause` @@ -1236,7 +1234,7 @@ Pause the container `id` - **404** – no such container - **500** – server error -### Unpause a container +#### Unpause a container `POST /containers/(id or name)/unpause` @@ -1256,7 +1254,7 @@ Unpause the container `id` - **404** – no such container - **500** – server error -### Attach to a container +#### Attach to a container `POST /containers/(id or name)/attach` @@ -1345,7 +1343,7 @@ The simplest way to implement the Attach protocol is the following: 4. Read the extracted size and output it on the correct output. 5. Goto 1. -### Attach to a container (websocket) +#### Attach to a container (websocket) `GET /containers/(id or name)/attach/ws` @@ -1385,7 +1383,7 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet - **404** – no such container - **500** – server error -### Wait a container +#### Wait a container `POST /containers/(id or name)/wait` @@ -1408,7 +1406,7 @@ Block until container `id` stops, then returns the exit code - **404** – no such container - **500** – server error -### Remove a container +#### Remove a container `DELETE /containers/(id or name)` @@ -1437,14 +1435,14 @@ Remove the container `id` from the filesystem - **409** – conflict - **500** – server error -### Retrieving information about files and folders in a container +#### Retrieving information about files and folders in a container `HEAD /containers/(id or name)/archive` See the description of the `X-Docker-Container-Path-Stat` header in the following section. -### Get an archive of a filesystem resource in a container +#### Get an archive of a filesystem resource in a container `GET /containers/(id or name)/archive` @@ -1509,7 +1507,7 @@ desired. - no such file or directory (**path** does not exist) - **500** - server error -### Extract an archive of files or folders to a directory in a container +#### Extract an archive of files or folders to a directory in a container `PUT /containers/(id or name)/archive` @@ -1557,9 +1555,9 @@ Upload a tar archive to be extracted to a path in the filesystem of container - no such file or directory (**path** resource does not exist) - **500** – server error -## 3.2 Images +### 3.2 Images -### List Images +#### List Images `GET /images/json` @@ -1652,7 +1650,7 @@ references on the command line. - `since`=(`[:]`, `` or ``) - **filter** - only return images with the specified name -### Build image from a Dockerfile +#### Build image from a Dockerfile `POST /build` @@ -1758,7 +1756,7 @@ or being killed. - **200** – no error - **500** – server error -### Create an image +#### Create an image `POST /images/create` @@ -1824,7 +1822,7 @@ a base64-encoded AuthConfig object. -### Inspect an image +#### Inspect an image `GET /images/(name)/json` @@ -1942,7 +1940,7 @@ Return low-level information on the image `name` - **404** – no such image - **500** – server error -### Get the history of an image +#### Get the history of an image `GET /images/(name)/history` @@ -1996,7 +1994,7 @@ Return the history of the image `name` - **404** – no such image - **500** – server error -### Push an image on the registry +#### Push an image on the registry `POST /images/(name)/push` @@ -2058,7 +2056,7 @@ The push is cancelled if the HTTP connection is closed. - **404** – no such image - **500** – server error -### Tag an image into a repository +#### Tag an image into a repository `POST /images/(name)/tag` @@ -2085,7 +2083,7 @@ Tag the image `name` into a repository - **409** – conflict - **500** – server error -### Remove an image +#### Remove an image `DELETE /images/(name)` @@ -2118,7 +2116,7 @@ Remove the image `name` from the filesystem - **409** – conflict - **500** – server error -### Search images +#### Search images `GET /images/search` @@ -2176,9 +2174,9 @@ Search for an image on [Docker Hub](https://hub.docker.com). - **200** – no error - **500** – server error -## 3.3 Misc +### 3.3 Misc -### Check auth configuration +#### Check auth configuration `POST /auth` @@ -2211,7 +2209,7 @@ if available, for accessing the registry without password. - **204** – no error - **500** – server error -### Display system-wide information +#### Display system-wide information `GET /info` @@ -2304,7 +2302,7 @@ Display system-wide information - **200** – no error - **500** – server error -### Show the docker version information +#### Show the docker version information `GET /version` @@ -2336,7 +2334,7 @@ Show the docker version information - **200** – no error - **500** – server error -### Ping the docker server +#### Ping the docker server `GET /_ping` @@ -2358,7 +2356,7 @@ Ping the docker server - **200** - no error - **500** - server error -### Create a new image from a container's changes +#### Create a new image from a container's changes `POST /commit` @@ -2430,7 +2428,7 @@ Create a new image from a container's changes - **404** – no such container - **500** – server error -### Monitor Docker's events +#### Monitor Docker's events `GET /events` @@ -2635,7 +2633,7 @@ Docker daemon report the following event: - **200** – no error - **500** – server error -### Get a tarball containing all images in a repository +#### Get a tarball containing all images in a repository `GET /images/(name)/get` @@ -2665,7 +2663,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Get a tarball containing all images +#### Get a tarball containing all images `GET /images/get` @@ -2694,7 +2692,7 @@ See the [image tarball format](#image-tarball-format) for more details. - **200** – no error - **500** – server error -### Load a tarball with a set of images and tags into docker +#### Load a tarball with a set of images and tags into docker `POST /images/load` @@ -2743,7 +2741,7 @@ action completes. - **200** – no error - **500** – server error -### Image tarball format +#### Image tarball format An image tarball contains one directory per image layer (named using its long ID), each containing these files: @@ -2764,7 +2762,7 @@ the root that contains a list of repository and tag names mapped to layer IDs. } ``` -### Exec Create +#### Exec Create `POST /containers/(id or name)/exec` @@ -2818,7 +2816,7 @@ Sets up an exec instance in a running container `id` - **409** - container is paused - **500** - server error -### Exec Start +#### Exec Start `POST /exec/(id)/start` @@ -2860,7 +2858,7 @@ interactive session with the `exec` command. Similar to the stream behavior of `POST /containers/(id or name)/attach` API -### Exec Resize +#### Exec Resize `POST /exec/(id)/resize` @@ -2887,7 +2885,7 @@ This API is valid only if `tty` was specified as part of creating and starting t - **201** – no error - **404** – no such exec instance -### Exec Inspect +#### Exec Inspect `GET /exec/(id)/json` @@ -2930,9 +2928,9 @@ Return low-level information about the `exec` command `id`. - **404** – no such exec instance - **500** - server error -## 3.4 Volumes +### 3.4 Volumes -### List volumes +#### List volumes `GET /volumes` @@ -2970,7 +2968,7 @@ Return low-level information about the `exec` command `id`. - **200** - no error - **500** - server error -### Create a volume +#### Create a volume `POST /volumes/create` @@ -3027,7 +3025,7 @@ Create a volume Refer to the [inspect a volume](#inspect-a-volume) section or details about the JSON fields returned in the response. -### Inspect a volume +#### Inspect a volume `GET /volumes/(name)` @@ -3079,7 +3077,7 @@ response. - **Scope** - Scope describes the level at which the volume exists, can be one of `global` for cluster-wide or `local` for machine level. The default is `local`. -### Remove a volume +#### Remove a volume `DELETE /volumes/(name)` @@ -3100,9 +3098,9 @@ Instruct the driver to remove the volume (`name`). - **409** - volume is in use and cannot be removed - **500** - server error -## 3.5 Networks +### 3.5 Networks -### List networks +#### List networks `GET /networks` @@ -3194,7 +3192,7 @@ Content-Type: application/json - **200** - no error - **500** - server error -### Inspect network +#### Inspect network `GET /networks/` @@ -3256,7 +3254,7 @@ Content-Type: application/json - **200** - no error - **404** - network not found -### Create a network +#### Create a network `POST /networks/create` @@ -3339,7 +3337,7 @@ Content-Type: application/json - **Options** - Network specific options to be used by the drivers - **Labels** - Labels to set on the network, specified as a map: `{"key":"value" [,"key2":"value2"]}` -### Connect a container to a network +#### Connect a container to a network `POST /networks/(id)/connect` @@ -3377,7 +3375,7 @@ Content-Type: application/json - **container** - container-id/name to be connected to the network -### Disconnect a container from a network +#### Disconnect a container from a network `POST /networks/(id)/disconnect` @@ -3411,7 +3409,7 @@ Content-Type: application/json - **Container** - container-id/name to be disconnected from a network - **Force** - Force the container to disconnect from a network -### Remove a network +#### Remove a network `DELETE /networks/(id)` @@ -3431,9 +3429,9 @@ Instruct the driver to remove the network (`id`). - **404** - no such network - **500** - server error -## 3.6 Plugins (experimental) +### 3.6 Plugins (experimental) -### List plugins +#### List plugins `GET /plugins` @@ -3563,7 +3561,7 @@ Content-Type: application/json - **200** - no error - **500** - server error -### Install a plugin +#### Install a plugin `POST /plugins/pull?name=` @@ -3625,7 +3623,7 @@ Content-Length: 175 name must have at least one component - **500** - plugin already exists -### Inspect a plugin +#### Inspect a plugin `GET /plugins/(plugin name)` @@ -3758,7 +3756,7 @@ Content-Type: application/json - **200** - no error - **404** - plugin not installed -### Enable a plugin +#### Enable a plugin `POST /plugins/(plugin name)/enable` @@ -3786,7 +3784,7 @@ Content-Type: text/plain; charset=utf-8 - **200** - no error - **500** - plugin is already enabled -### Disable a plugin +#### Disable a plugin `POST /plugins/(plugin name)/disable` @@ -3814,7 +3812,7 @@ Content-Type: text/plain; charset=utf-8 - **200** - no error - **500** - plugin is already disabled -### Remove a plugin +#### Remove a plugin `DELETE /plugins/(plugin name)` @@ -3844,7 +3842,7 @@ Content-Type: text/plain; charset=utf-8 -## 3.7 Nodes +### 3.7 Nodes **Note**: Node operations require the engine to be part of a swarm. -### List nodes +#### List nodes `GET /nodes` @@ -3967,7 +3965,7 @@ List nodes - **200** – no error - **500** – server error -### Inspect a node +#### Inspect a node `GET /nodes/(id or name)` @@ -4049,7 +4047,7 @@ Return low-level information on the node `id` - **404** – no such node - **500** – server error -### Remove a node +#### Remove a node `DELETE /nodes/(id or name)` @@ -4077,7 +4075,7 @@ Remove a node from the swarm. - **404** – no such node - **500** – server error -### Update a node +#### Update a node `POST /nodes/(id)/update` @@ -4132,9 +4130,9 @@ JSON Parameters: - **404** – no such node - **500** – server error -## 3.8 Swarm +### 3.8 Swarm -### Inspect swarm +#### Inspect swarm `GET /swarm` @@ -4182,7 +4180,7 @@ Inspect swarm - **200** - no error -### Initialize a new swarm +#### Initialize a new swarm `POST /swarm/init` @@ -4258,7 +4256,7 @@ JSON Parameters: - **Options** - An object with key/value pairs that are interpreted as protocol-specific options for the external CA driver. -### Join an existing swarm +#### Join an existing swarm `POST /swarm/join` @@ -4300,7 +4298,7 @@ JSON Parameters: - **RemoteAddr** – Address of any manager node already participating in the swarm. - **JoinToken** – Secret token for joining this swarm. -### Leave a swarm +#### Leave a swarm `POST /swarm/leave` @@ -4326,7 +4324,7 @@ Leave a swarm - **200** – no error - **406** – node is not part of a swarm -### Update a swarm +#### Update a swarm `POST /swarm/update` @@ -4407,11 +4405,11 @@ JSON Parameters: - **Worker** - Token to use for joining as a worker. - **Manager** - Token to use for joining as a manager. -## 3.9 Services +### 3.9 Services **Note**: Service operations require to first be part of a swarm. -### List services +#### List services `GET /services` @@ -4516,7 +4514,7 @@ List services - **200** – no error - **500** – server error -### Create a service +#### Create a service `POST /services/create` @@ -4689,7 +4687,7 @@ image](#create-an-image) section for more details. section for more details. -### Remove a service +#### Remove a service `DELETE /services/(id or name)` @@ -4712,7 +4710,7 @@ Stop and remove the service `id` - **404** – no such service - **500** – server error -### Inspect one or more services +#### Inspect one or more services `GET /services/(id or name)` @@ -4801,7 +4799,7 @@ Return information on the service `id`. - **404** – no such service - **500** – server error -### Update a service +#### Update a service `POST /services/(id or name)/update` @@ -4934,11 +4932,11 @@ image](#create-an-image) section for more details. - **404** – no such service - **500** – server error -## 3.10 Tasks +### 3.10 Tasks **Note**: Task operations require the engine to be part of a swarm. -### List tasks +#### List tasks `GET /tasks` @@ -5136,7 +5134,7 @@ List tasks - **200** – no error - **500** – server error -### Inspect a task +#### Inspect a task `GET /tasks/(task id)` @@ -5239,9 +5237,9 @@ Get details on a task - **404** – unknown task - **500** – server error -# 4. Going further +## 4. Going further -## 4.1 Inside `docker run` +### 4.1 Inside `docker run` As an example, the `docker run` command line makes the following API calls: @@ -5259,7 +5257,7 @@ As an example, the `docker run` command line makes the following API calls: - If in detached mode or only `stdin` is attached, display the container's id. -## 4.2 Hijacking +### 4.2 Hijacking In this version of the API, `/attach`, uses hijacking to transport `stdin`, `stdout`, and `stderr` on the same socket. @@ -5274,7 +5272,7 @@ When Docker daemon detects the `Upgrade` header, it switches its status code from **200 OK** to **101 UPGRADED** and resends the same headers. -## 4.3 CORS Requests +### 4.3 CORS Requests To set cross origin requests to the Engine API please give values to `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, diff --git a/docs/api/version-history.md b/docs/api/version-history.md index 3e4871dece43b5ea004082c5751c1f7a2a9b33a9..4e3de96e979d7c629da22fac5442d622313c8301 100644 --- a/docs/api/version-history.md +++ b/docs/api/version-history.md @@ -72,7 +72,11 @@ keywords: "API, Docker, rcli, REST, documentation" * `DELETE /plugins/(plugin name)` delete a plugin. * `POST /node/(id or name)/update` now accepts both `id` or `name` to identify the node to update. * `GET /images/json` now support a `reference` filter. - +* `GET /secrets` returns information on the secrets. +* `POST /secrets/create` creates a secret. +* `DELETE /secrets/{id}` removes the secret `id`. +* `GET /secrets/{id}` returns information on the secret `id`. +* `POST /secrets/{id}/update` updates the secret `id`. ## v1.24 API changes diff --git a/docs/deprecated.md b/docs/deprecated.md index 553a9025723e169dac13c3cf0e4686c922f73fee..d6cfef5d033a81e1902bd69f7b952294bee0de15 100644 --- a/docs/deprecated.md +++ b/docs/deprecated.md @@ -32,7 +32,7 @@ The `filter` param to filter the list of image by reference (name or name:tag) i **Target For Removal In Release: v1.16** -`repository:shortid` syntax for referencing images is very little used, collides with with tag references can be confused with digest references. +`repository:shortid` syntax for referencing images is very little used, collides with tag references can be confused with digest references. ### `docker daemon` subcommand **Deprecated In Release: [v1.13](https://github.com/docker/docker/releases/tag/v1.13.0)** diff --git a/docs/reference/commandline/create.md b/docs/reference/commandline/create.md index 9fdfd4c20593d6d12d0b4f88bbe5f695111b87c7..0218af3a7690833e8cb61c6c7043b4405a73deb0 100644 --- a/docs/reference/commandline/create.md +++ b/docs/reference/commandline/create.md @@ -82,7 +82,6 @@ Options: --memory-reservation string Memory soft limit --memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) - --mount value Attach a filesytem mount to the container (default []) --name string Assign a name to the container --network-alias value Add network-scoped alias for the container (default []) --network string Connect a container to a network (default "default") diff --git a/docs/reference/commandline/node_ps.md b/docs/reference/commandline/node_ps.md index 7a4054bebedb441f5612fa3b48ba44a22b5b8bc1..0c54c9cfb03f22c189e76664d72265687a700a59 100644 --- a/docs/reference/commandline/node_ps.md +++ b/docs/reference/commandline/node_ps.md @@ -22,7 +22,7 @@ Usage: docker node ps [OPTIONS] [NODE...] List tasks running on one or more nodes, defaults to current node. Options: - -a, --all Show all tasks (default shows tasks that are or will be running) + -a, --all Display all instances -f, --filter value Filter output based on conditions provided --help Print usage --no-resolve Do not map IDs to Names diff --git a/docs/reference/commandline/plugin_inspect.md b/docs/reference/commandline/plugin_inspect.md index 80b8e8c881095a4eadd6ac7bc02040ac32e5f79e..9e09e0c5876bb0ad343f7da170880bcac53b6772 100644 --- a/docs/reference/commandline/plugin_inspect.md +++ b/docs/reference/commandline/plugin_inspect.md @@ -16,13 +16,13 @@ keywords: "plugin, inspect" # plugin inspect ```markdown -Usage: docker plugin inspect [OPTIONS] PLUGIN [PLUGIN...] +Usage: docker plugin inspect [OPTIONS] PLUGIN|ID [PLUGIN|ID...] Display detailed information on one or more plugins Options: - -f, --format string Format the output using the given Go template - --help Print usage + -f, --format string Format the output using the given Go template + --help Print usage ``` Returns information about a plugin. By default, this command renders all results diff --git a/docs/reference/commandline/run.md b/docs/reference/commandline/run.md index 6c845e40a89b736a7ab17d6e12e57de7ca9ed1e4..619564701224c2b1d898aaadb0b3ed097f8ed8f6 100644 --- a/docs/reference/commandline/run.md +++ b/docs/reference/commandline/run.md @@ -92,7 +92,6 @@ Options: --memory-reservation string Memory soft limit --memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) - --mount value Attach a filesystem mount to the container (default []) --name string Assign a name to the container --network-alias value Add network-scoped alias for the container (default []) --network string Connect a container to a network @@ -284,21 +283,6 @@ of a bind mount must be a local directory, not a file. For in-depth information about volumes, refer to [manage data in containers](https://docs.docker.com/engine/tutorials/dockervolumes/) -### Add bin-mounts or volumes using the --mount flag - -The `--mount` flag allows you to mount volumes, host-directories and `tmpfs` -mounts in a container. - -The `--mount` flag supports most options that are supported by the `-v` or the -`--volume` flag, but uses a different syntax. For in-depth information on the -`--mount` flag, and a comparison between `--volume` and `--mount`, refer to -the [service create command reference](service_create.md#add-bind-mounts-or-volumes). - -Examples: - - $ docker run --read-only --mount type=volume,target=/icanwrite busybox touch /icanwrite/here - $ docker run -t -i --mount type=bind,src=/data,dst=/data busybox sh - ### Publish or expose port (-p, --expose) $ docker run -p 127.0.0.1:80:8080 ubuntu bash @@ -678,7 +662,7 @@ The `credentialspec` must be in the format `file://spec.txt` or `registry://keyn ### Stop container with timeout (--stop-timeout) -The `--stop-timeout` flag sets the the timeout (in seconds) that a pre-defined (see `--stop-signal`) system call +The `--stop-timeout` flag sets the timeout (in seconds) that a pre-defined (see `--stop-signal`) system call signal that will be sent to the container to exit. After timeout elapses the container will be killed with SIGKILL. ### Specify isolation technology for container (--isolation) diff --git a/docs/reference/commandline/secret_ls.md b/docs/reference/commandline/secret_ls.md index 31659e72e617d9880335e5dd89fcf2969c705445..6b34fc2146316b7fe880a4515845d9f54018036f 100644 --- a/docs/reference/commandline/secret_ls.md +++ b/docs/reference/commandline/secret_ls.md @@ -27,9 +27,9 @@ Options: -q, --quiet Only display IDs ``` -Run this command from a manager to list the secrets in the Swarm. +Run this command on a manager node to list the secrets in the Swarm. -On a manager node: +## Examples ```bash $ docker secret ls diff --git a/docs/reference/commandline/service_ps.md b/docs/reference/commandline/service_ps.md index 2554267f392006355f8a9e36e521abe6de7086a0..b824f53dab64770f63929cd72b7a25718bd9a311 100644 --- a/docs/reference/commandline/service_ps.md +++ b/docs/reference/commandline/service_ps.md @@ -22,7 +22,6 @@ Usage: docker service ps [OPTIONS] SERVICE List the tasks of a service Options: - -a, --all Show all tasks (default shows tasks that are or will be running) -f, --filter filter Filter output based on conditions provided --help Print usage --no-resolve Do not map IDs to Names diff --git a/docs/reference/glossary.md b/docs/reference/glossary.md index 94bd1ceec5099ed0f25988601ac5e32139d62daf..0bc39a202350998a6adda267316290e4b7a30a64 100644 --- a/docs/reference/glossary.md +++ b/docs/reference/glossary.md @@ -280,7 +280,7 @@ A virtual machine is a program that emulates a complete computer and imitates de It shares physical hardware resources with other users but isolates the operating system. The end user has the same experience on a Virtual Machine as they would have on dedicated hardware. -Compared to to containers, a virtual machine is heavier to run, provides more isolation, +Compared to containers, a virtual machine is heavier to run, provides more isolation, gets its own set of resources and does minimal sharing. *Also known as : VM* diff --git a/hack/validate/swagger-gen b/hack/validate/swagger-gen index 37ced76e8cda2f0aed517f6be088ec9772246e33..42c97493600d150d8c8d0d8d11f7c4757f567a66 100755 --- a/hack/validate/swagger-gen +++ b/hack/validate/swagger-gen @@ -4,7 +4,7 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source "${SCRIPTDIR}/.validate" IFS=$'\n' -files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' || true) ) +files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' 'api/swagger.yaml' || true) ) unset IFS if [ ${#files[@]} -gt 0 ]; then @@ -26,5 +26,5 @@ if [ ${#files[@]} -gt 0 ]; then echo 'Congratulations! All api changes are done the right way.' fi else - echo 'No api/types/ changes in diff.' + echo 'No api/types/ or api/swagger.yaml changes in diff.' fi diff --git a/image/tarexport/save.go b/image/tarexport/save.go index cd5c82dc104d73ff263f70c360ba0f903b2eb48f..6e3a5bc589d0fda2eeee623af6a2fedbc9647601 100644 --- a/image/tarexport/save.go +++ b/image/tarexport/save.go @@ -234,7 +234,9 @@ func (s *saveSession) saveImage(id image.ID) (map[layer.DiffID]distribution.Desc var layers []string var foreignSrcs map[layer.DiffID]distribution.Descriptor for i := range img.RootFS.DiffIDs { - v1Img := image.V1Image{} + v1Img := image.V1Image{ + Created: img.Created, + } if i == len(img.RootFS.DiffIDs)-1 { v1Img = img.V1Image } diff --git a/integration-cli/daemon_swarm.go b/integration-cli/daemon_swarm.go index cb364f0443da329e83eeba5f537a8f38ae6a8b47..a5039971a3df049c1158927bbf9fc8289d0551ea 100644 --- a/integration-cli/daemon_swarm.go +++ b/integration-cli/daemon_swarm.go @@ -317,7 +317,7 @@ func (d *SwarmDaemon) getSecret(c *check.C, id string) *swarm.Secret { func (d *SwarmDaemon) deleteSecret(c *check.C, id string) { status, out, err := d.SockRequest("DELETE", "/secrets/"+id, nil) c.Assert(err, checker.IsNil, check.Commentf(string(out))) - c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out))) + c.Assert(status, checker.Equals, http.StatusNoContent, check.Commentf("output: %q", string(out))) } func (d *SwarmDaemon) getSwarm(c *check.C) swarm.Swarm { diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index cd3dd30a0fa869053ae25a45ecd70d262999fc21..d046ec06847fabd4a1aa631f33622bcf25a631de 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -728,7 +728,7 @@ func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *check.C) { c.Assert(string(b[:]), checker.Contains, "invalid port") } -func (s *DockerSuite) TestContainerAPIInvalidRestartPolicyName(c *check.C) { +func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *check.C) { config := `{ "Image": "busybox", "HostConfig": { @@ -748,7 +748,7 @@ func (s *DockerSuite) TestContainerAPIInvalidRestartPolicyName(c *check.C) { c.Assert(string(b[:]), checker.Contains, "invalid restart policy") } -func (s *DockerSuite) TestContainerAPIInvalidRestartPolicyRetryMismatch(c *check.C) { +func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *check.C) { config := `{ "Image": "busybox", "HostConfig": { @@ -765,10 +765,10 @@ func (s *DockerSuite) TestContainerAPIInvalidRestartPolicyRetryMismatch(c *check b, err := readBody(body) c.Assert(err, checker.IsNil) - c.Assert(string(b[:]), checker.Contains, "maximum restart count not valid with restart policy") + c.Assert(string(b[:]), checker.Contains, "maximum retry count cannot be used with restart policy") } -func (s *DockerSuite) TestContainerAPIInvalidRestartPolicyPositiveRetryCount(c *check.C) { +func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *check.C) { config := `{ "Image": "busybox", "HostConfig": { @@ -785,7 +785,23 @@ func (s *DockerSuite) TestContainerAPIInvalidRestartPolicyPositiveRetryCount(c * b, err := readBody(body) c.Assert(err, checker.IsNil) - c.Assert(string(b[:]), checker.Contains, "maximum restart count must be a positive integer") + c.Assert(string(b[:]), checker.Contains, "maximum retry count cannot be negative") +} + +func (s *DockerSuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *check.C) { + config := `{ + "Image": "busybox", + "HostConfig": { + "RestartPolicy": { + "Name": "on-failure", + "MaximumRetryCount": 0 + } + } + }` + + res, _, err := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json") + c.Assert(err, checker.IsNil) + c.Assert(res.StatusCode, checker.Equals, http.StatusCreated) } // Issue 7941 - test to make sure a "null" in JSON is just ignored. diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index eea4712fe70da65a97e96f8d6000815cd7cbcb4f..e11f22d2f133419752e6caa6bcbda1dfbf1c94a8 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -7311,3 +7311,19 @@ RUN ["cat", "/foo/file"] c.Fatal(err) } } + +// Case-insensitive environment variables on Windows +func (s *DockerSuite) TestBuildWindowsEnvCaseInsensitive(c *check.C) { + testRequires(c, DaemonIsWindows) + name := "testbuildwindowsenvcaseinsensitive" + if _, err := buildImage(name, ` + FROM `+WindowsBaseImage+` + ENV FOO=bar foo=bar + `, true); err != nil { + c.Fatal(err) + } + res := inspectFieldJSON(c, name, "Config.Env") + if res != `["foo=bar"]` { // Should not have FOO=bar in it - takes the last one processed. And only one entry as deduped. + c.Fatalf("Case insensitive environment variables on Windows failed. Got %s", res) + } +} diff --git a/integration-cli/docker_cli_plugins_test.go b/integration-cli/docker_cli_plugins_test.go index f6d2f28b54966dafed2536ed30bc999cc042774c..730580e568b34c112359d3edc867fbdb96744391 100644 --- a/integration-cli/docker_cli_plugins_test.go +++ b/integration-cli/docker_cli_plugins_test.go @@ -201,3 +201,52 @@ func (s *DockerSuite) TestPluginCreate(c *check.C) { // The output will consists of one HEADER line and one line of foo/bar-driver c.Assert(len(strings.Split(strings.TrimSpace(out), "\n")), checker.Equals, 2) } + +func (s *DockerSuite) TestPluginInspect(c *check.C) { + testRequires(c, DaemonIsLinux, Network) + _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) + c.Assert(err, checker.IsNil) + + out, _, err := dockerCmdWithError("plugin", "ls") + c.Assert(err, checker.IsNil) + c.Assert(out, checker.Contains, pName) + c.Assert(out, checker.Contains, pTag) + c.Assert(out, checker.Contains, "true") + + // Find the ID first + out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag) + c.Assert(err, checker.IsNil) + id := strings.TrimSpace(out) + c.Assert(id, checker.Not(checker.Equals), "") + + // Long form + out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id) + c.Assert(err, checker.IsNil) + c.Assert(strings.TrimSpace(out), checker.Equals, id) + + // Short form + out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id[:5]) + c.Assert(err, checker.IsNil) + c.Assert(strings.TrimSpace(out), checker.Equals, id) + + // Name with tag form + out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag) + c.Assert(err, checker.IsNil) + c.Assert(strings.TrimSpace(out), checker.Equals, id) + + // Name without tag form + out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pName) + c.Assert(err, checker.IsNil) + c.Assert(strings.TrimSpace(out), checker.Equals, id) + + _, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag) + c.Assert(err, checker.IsNil) + + out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag) + c.Assert(err, checker.IsNil) + c.Assert(out, checker.Contains, pNameWithTag) + + // After remove nothing should be found + _, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id[:5]) + c.Assert(err, checker.NotNil) +} diff --git a/integration-cli/docker_cli_restart_test.go b/integration-cli/docker_cli_restart_test.go index ca71aaa144b918c34b262029674afaf671dc1fe1..7d585289eb7de949da85efe3c67eea30729bf6d7 100644 --- a/integration-cli/docker_cli_restart_test.go +++ b/integration-cli/docker_cli_restart_test.go @@ -74,7 +74,7 @@ func (s *DockerSuite) TestRestartWithVolumes(c *check.C) { } func (s *DockerSuite) TestRestartPolicyNO(c *check.C) { - out, _ := dockerCmd(c, "run", "-d", "--restart=no", "busybox", "false") + out, _ := dockerCmd(c, "create", "--restart=no", "busybox") id := strings.TrimSpace(string(out)) name := inspectField(c, id, "HostConfig.RestartPolicy.Name") @@ -82,7 +82,7 @@ func (s *DockerSuite) TestRestartPolicyNO(c *check.C) { } func (s *DockerSuite) TestRestartPolicyAlways(c *check.C) { - out, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "false") + out, _ := dockerCmd(c, "create", "--restart=always", "busybox") id := strings.TrimSpace(string(out)) name := inspectField(c, id, "HostConfig.RestartPolicy.Name") @@ -95,12 +95,36 @@ func (s *DockerSuite) TestRestartPolicyAlways(c *check.C) { } func (s *DockerSuite) TestRestartPolicyOnFailure(c *check.C) { - out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:1", "busybox", "false") + out, _, err := dockerCmdWithError("create", "--restart=on-failure:-1", "busybox") + c.Assert(err, check.NotNil, check.Commentf(out)) + c.Assert(out, checker.Contains, "maximum retry count cannot be negative") + + out, _ = dockerCmd(c, "create", "--restart=on-failure:1", "busybox") id := strings.TrimSpace(string(out)) name := inspectField(c, id, "HostConfig.RestartPolicy.Name") + maxRetry := inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount") + c.Assert(name, checker.Equals, "on-failure") + c.Assert(maxRetry, checker.Equals, "1") + + out, _ = dockerCmd(c, "create", "--restart=on-failure:0", "busybox") + id = strings.TrimSpace(string(out)) + name = inspectField(c, id, "HostConfig.RestartPolicy.Name") + maxRetry = inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount") + + c.Assert(name, checker.Equals, "on-failure") + c.Assert(maxRetry, checker.Equals, "0") + + out, _ = dockerCmd(c, "create", "--restart=on-failure", "busybox") + + id = strings.TrimSpace(string(out)) + name = inspectField(c, id, "HostConfig.RestartPolicy.Name") + maxRetry = inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount") + + c.Assert(name, checker.Equals, "on-failure") + c.Assert(maxRetry, checker.Equals, "0") } // a good container with --restart=on-failure:3 diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index dd3f4cef3285e78443f8613c4992f861d0453223..2f451e3c3abeb9245b226ffe0a07a5704835b6c6 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -4590,184 +4590,6 @@ func (s *DockerSuite) TestRunDuplicateMount(c *check.C) { c.Assert(out, checker.Contains, "null") } -func (s *DockerSuite) TestRunMount(c *check.C) { - testRequires(c, DaemonIsLinux, SameHostDaemon, NotUserNamespace) - - // mnt1, mnt2, and testCatFooBar are commonly used in multiple test cases - tmpDir, err := ioutil.TempDir("", "mount") - if err != nil { - c.Fatal(err) - } - defer os.RemoveAll(tmpDir) - mnt1, mnt2 := path.Join(tmpDir, "mnt1"), path.Join(tmpDir, "mnt2") - if err := os.Mkdir(mnt1, 0755); err != nil { - c.Fatal(err) - } - if err := os.Mkdir(mnt2, 0755); err != nil { - c.Fatal(err) - } - if err := ioutil.WriteFile(path.Join(mnt1, "test1"), []byte("test1"), 0644); err != nil { - c.Fatal(err) - } - if err := ioutil.WriteFile(path.Join(mnt2, "test2"), []byte("test2"), 0644); err != nil { - c.Fatal(err) - } - testCatFooBar := func(cName string) error { - out, _ := dockerCmd(c, "exec", cName, "cat", "/foo/test1") - if out != "test1" { - return fmt.Errorf("%s not mounted on /foo", mnt1) - } - out, _ = dockerCmd(c, "exec", cName, "cat", "/bar/test2") - if out != "test2" { - return fmt.Errorf("%s not mounted on /bar", mnt2) - } - return nil - } - - type testCase struct { - equivalents [][]string - valid bool - // fn should be nil if valid==false - fn func(cName string) error - } - cases := []testCase{ - { - equivalents: [][]string{ - { - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/bar", mnt2), - }, - { - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,target=/bar", mnt2), - }, - { - "--volume", fmt.Sprintf("%s:/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,target=/bar", mnt2), - }, - }, - valid: true, - fn: testCatFooBar, - }, - { - equivalents: [][]string{ - { - "--mount", fmt.Sprintf("type=volume,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=volume,src=%s,dst=/bar", mnt2), - }, - { - "--mount", fmt.Sprintf("type=volume,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=volume,src=%s,target=/bar", mnt2), - }, - }, - valid: false, - }, - { - equivalents: [][]string{ - { - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=volume,src=%s,dst=/bar", mnt2), - }, - { - "--volume", fmt.Sprintf("%s:/foo", mnt1), - "--mount", fmt.Sprintf("type=volume,src=%s,target=/bar", mnt2), - }, - }, - valid: false, - fn: testCatFooBar, - }, - { - equivalents: [][]string{ - { - "--read-only", - "--mount", "type=volume,dst=/bar", - }, - }, - valid: true, - fn: func(cName string) error { - _, _, err := dockerCmdWithError("exec", cName, "touch", "/bar/icanwritehere") - return err - }, - }, - { - equivalents: [][]string{ - { - "--read-only", - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", "type=volume,dst=/bar", - }, - { - "--read-only", - "--volume", fmt.Sprintf("%s:/foo", mnt1), - "--mount", "type=volume,dst=/bar", - }, - }, - valid: true, - fn: func(cName string) error { - out, _ := dockerCmd(c, "exec", cName, "cat", "/foo/test1") - if out != "test1" { - return fmt.Errorf("%s not mounted on /foo", mnt1) - } - _, _, err := dockerCmdWithError("exec", cName, "touch", "/bar/icanwritehere") - return err - }, - }, - { - equivalents: [][]string{ - { - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt2), - }, - { - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,target=/foo", mnt2), - }, - { - "--volume", fmt.Sprintf("%s:/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,target=/foo", mnt2), - }, - }, - valid: false, - }, - { - equivalents: [][]string{ - { - "--volume", fmt.Sprintf("%s:/foo", mnt1), - "--mount", fmt.Sprintf("type=volume,src=%s,target=/foo", mnt2), - }, - }, - valid: false, - }, - { - equivalents: [][]string{ - { - "--mount", "type=volume,target=/foo", - "--mount", "type=volume,target=/foo", - }, - }, - valid: false, - }, - } - - for i, testCase := range cases { - for j, opts := range testCase.equivalents { - cName := fmt.Sprintf("mount-%d-%d", i, j) - _, _, err := dockerCmdWithError(append([]string{"run", "-i", "-d", "--name", cName}, - append(opts, []string{"busybox", "top"}...)...)...) - if testCase.valid { - c.Assert(err, check.IsNil, - check.Commentf("got error while creating a container with %v (%s)", opts, cName)) - c.Assert(testCase.fn(cName), check.IsNil, - check.Commentf("got error while executing test for %v (%s)", opts, cName)) - dockerCmd(c, "rm", "-f", cName) - } else { - c.Assert(err, checker.NotNil, - check.Commentf("got nil while creating a container with %v (%s)", opts, cName)) - } - } - } -} - func (s *DockerSuite) TestRunWindowsWithCPUCount(c *check.C) { testRequires(c, DaemonIsWindows) diff --git a/integration-cli/docker_cli_service_create_test.go b/integration-cli/docker_cli_service_create_test.go index 8b838b5aad60f97d71ffb408451bde417d05d5ae..9e8b1e995676d96cd5339766055a11a8effd0cbe 100644 --- a/integration-cli/docker_cli_service_create_test.go +++ b/integration-cli/docker_cli_service_create_test.go @@ -123,7 +123,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTarget(c *check.C) { func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *check.C) { d := s.AddDaemon(c, true, true) - out, err := d.Cmd("service", "create", "--mount", "type=tmpfs,target=/foo", "busybox", "sh", "-c", "mount | grep foo; tail -f /dev/null") + out, err := d.Cmd("service", "create", "--mount", "type=tmpfs,target=/foo,tmpfs-size=1MB", "busybox", "sh", "-c", "mount | grep foo; tail -f /dev/null") c.Assert(err, checker.IsNil, check.Commentf(out)) id := strings.TrimSpace(out) @@ -152,6 +152,8 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *check.C) { c.Assert(mountConfig[0].Source, checker.Equals, "") c.Assert(mountConfig[0].Target, checker.Equals, "/foo") c.Assert(mountConfig[0].Type, checker.Equals, mount.TypeTmpfs) + c.Assert(mountConfig[0].TmpfsOptions, checker.NotNil) + c.Assert(mountConfig[0].TmpfsOptions.SizeBytes, checker.Equals, int64(1048576)) // check container mounts actual out, err = s.nodeCmd(c, task.NodeID, "inspect", "--format", "{{json .Mounts}}", task.Status.ContainerStatus.ContainerID) @@ -169,4 +171,5 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *check.C) { out, err = s.nodeCmd(c, task.NodeID, "logs", task.Status.ContainerStatus.ContainerID) c.Assert(err, checker.IsNil, check.Commentf(out)) c.Assert(strings.TrimSpace(out), checker.HasPrefix, "tmpfs on /foo type tmpfs") + c.Assert(strings.TrimSpace(out), checker.Contains, "size=1024k") } diff --git a/integration-cli/docker_cli_swarm_test.go b/integration-cli/docker_cli_swarm_test.go index fc343a1c1795bff33d03658b5078e9c75d61a6df..b9a2ca7652d6dd926afb27d42fbf8b8d595d44c8 100644 --- a/integration-cli/docker_cli_swarm_test.go +++ b/integration-cli/docker_cli_swarm_test.go @@ -226,88 +226,6 @@ func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *check.C) { c.Assert(out, checker.Not(checker.Contains), name+".1") c.Assert(out, checker.Not(checker.Contains), name+".2") c.Assert(out, checker.Not(checker.Contains), name+".3") - - out, err = d.Cmd("node", "ps", "--filter", "desired-state=running", "self") - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, name+".1") - c.Assert(out, checker.Contains, name+".2") - c.Assert(out, checker.Contains, name+".3") - - out, err = d.Cmd("node", "ps", "--filter", "desired-state=shutdown", "self") - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Not(checker.Contains), name+".1") - c.Assert(out, checker.Not(checker.Contains), name+".2") - c.Assert(out, checker.Not(checker.Contains), name+".3") -} - -func (s *DockerSwarmSuite) TestSwarmServiceTaskListAll(c *check.C) { - d := s.AddDaemon(c, true, true) - - name := "service-task-list-1" - out, err := d.Cmd("service", "create", "--name", name, "--replicas=3", "busybox", "top") - c.Assert(err, checker.IsNil) - c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "") - - // make sure task has been deployed. - waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, 3) - - out, err = d.Cmd("service", "ps", name) - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, name+".1") - c.Assert(out, checker.Contains, name+".2") - c.Assert(out, checker.Contains, name+".3") - - // Get the last container id so we can restart it to cause a task error in the history - containerID, err := d.Cmd("ps", "-q", "-l") - c.Assert(err, checker.IsNil) - - _, err = d.Cmd("stop", strings.TrimSpace(containerID)) - c.Assert(err, checker.IsNil) - - waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, 3) - - out, err = d.Cmd("service", "ps", name) - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Count, name, 3) - - out, err = d.Cmd("service", "ps", name, "-a") - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Count, name, 4) -} - -func (s *DockerSwarmSuite) TestSwarmNodeTaskListAll(c *check.C) { - d := s.AddDaemon(c, true, true) - - name := "node-task-list" - out, err := d.Cmd("service", "create", "--name", name, "--replicas=3", "busybox", "top") - c.Assert(err, checker.IsNil) - c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "") - - // make sure task has been deployed. - waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, 3) - - out, err = d.Cmd("service", "ps", name) - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, name+".1") - c.Assert(out, checker.Contains, name+".2") - c.Assert(out, checker.Contains, name+".3") - - // Get the last container id so we can restart it to cause a task error in the history - containerID, err := d.Cmd("ps", "-q", "-l") - c.Assert(err, checker.IsNil) - - _, err = d.Cmd("stop", strings.TrimSpace(containerID)) - c.Assert(err, checker.IsNil) - - waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, 3) - - out, err = d.Cmd("node", "ps", "self") - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Count, name, 3) - - out, err = d.Cmd("node", "ps", "self", "-a") - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Count, name, 4) } // Test case for #25375 diff --git a/libcontainerd/client_linux.go b/libcontainerd/client_linux.go index b67690b12b34956c4166a3d9018bcc9ddcf71b76..657eda2c0dc41901bc17cd6dfc58a372674006d9 100644 --- a/libcontainerd/client_linux.go +++ b/libcontainerd/client_linux.go @@ -405,13 +405,8 @@ func (clnt *client) getContainerLastEventSinceTime(id string, tsp *timestamp.Tim logrus.Errorf("libcontainerd: failed to get container event for %s: %q", id, err) return nil, err } - - logrus.Debugf("libcontainerd: received past event %#v", e) - - switch e.Type { - case StateExit, StatePause, StateResume: - ev = e - } + ev = e + logrus.Debugf("libcontainerd: received past event %#v", ev) } return ev, nil @@ -456,30 +451,36 @@ func (clnt *client) Restore(containerID string, attachStdio StdioCallback, optio // Get its last event ev, eerr := clnt.getContainerLastEvent(containerID) if err != nil || cont.Status == "Stopped" { - if err != nil && !strings.Contains(err.Error(), "container not found") { - // Legitimate error - return err + if err != nil { + logrus.Warnf("libcontainerd: failed to retrieve container %s state: %v", containerID, err) } - - if ev == nil { - if _, err := clnt.getContainer(containerID); err == nil { - // If ev is nil and the container is running in containerd, - // we already consumed all the event of the - // container, included the "exit" one. - // Thus we return to avoid overriding the Exit Code. - logrus.Warnf("libcontainerd: restore was called on a fully synced container (%s)", containerID) - return nil - } - // the container is not running so we need to fix the state within docker - ev = &containerd.Event{ - Type: StateExit, - Status: 1, + if ev != nil && (ev.Pid != InitFriendlyName || ev.Type != StateExit) { + // Wait a while for the exit event + timeout := time.NewTimer(10 * time.Second) + tick := time.NewTicker(100 * time.Millisecond) + stop: + for { + select { + case <-timeout.C: + break stop + case <-tick.C: + ev, eerr = clnt.getContainerLastEvent(containerID) + if eerr != nil { + break stop + } + if ev != nil && ev.Pid == InitFriendlyName && ev.Type == StateExit { + break stop + } + } } + timeout.Stop() + tick.Stop() } - // get the exit status for this container - ec := uint32(0) - if eerr == nil && ev.Type == StateExit { + // get the exit status for this container, if we don't have + // one, indicate an error + ec := uint32(255) + if eerr == nil && ev != nil && ev.Pid == InitFriendlyName && ev.Type == StateExit { ec = ev.Status } clnt.setExited(containerID, ec) diff --git a/libcontainerd/process_unix.go b/libcontainerd/process_unix.go index e3d8c5f34ad32bacc73d4b600fc91d847c1b58f3..514ebf643c112e8e5b0036299b47b811da2faf8a 100644 --- a/libcontainerd/process_unix.go +++ b/libcontainerd/process_unix.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" goruntime "runtime" + "strings" "time" containerd "github.com/docker/containerd/api/grpc/types" @@ -86,6 +87,9 @@ func (p *process) sendCloseStdin() error { Pid: p.friendlyName, CloseStdin: true, }) + if err != nil && (strings.Contains(err.Error(), "container not found") || strings.Contains(err.Error(), "process not found")) { + return nil + } return err } diff --git a/man/docker-build.1.md b/man/docker-build.1.md index 32caaafc74e446bcebf5cd4adfb53d70cd8930d4..aef3414879acb51acbeb78f3fe797fc84e897c9f 100644 --- a/man/docker-build.1.md +++ b/man/docker-build.1.md @@ -83,7 +83,7 @@ set as the **URL**, the repository is cloned locally and then sent as the contex Users pass these values at build-time. Docker uses the `buildargs` as the environment context for command(s) run via the Dockerfile's `RUN` instruction or for variable expansion in other Dockerfile instructions. This is not meant - for passing secret values. [Read more about the buildargs instruction](/reference/builder/#arg) + for passing secret values. [Read more about the buildargs instruction](https://docs.docker.com/engine/reference/builder/#arg) **--force-rm**=*true*|*false* Always remove intermediate containers, even after unsuccessful builds. The default is *false*. diff --git a/man/docker-create.1.md b/man/docker-create.1.md index 8bb162c2c3c01f2e10f2b429515913d23057aa08..a819904efa71c29a459b6374c3c3a2240641778b 100644 --- a/man/docker-create.1.md +++ b/man/docker-create.1.md @@ -56,7 +56,6 @@ docker-create - Create a new container [**--memory-reservation**[=*MEMORY-RESERVATION*]] [**--memory-swap**[=*LIMIT*]] [**--memory-swappiness**[=*MEMORY-SWAPPINESS*]] -[**--mount**[=*MOUNT*]] [**--name**[=*NAME*]] [**--network-alias**[=*[]*]] [**--network**[=*"bridge"*]] diff --git a/man/docker-login.1.md b/man/docker-login.1.md index 6bb0355946cc8d6da5832e7d00b61468af9cf0af..c0d4f795db3954cab0a0fc5636b010ebc2c11ddb 100644 --- a/man/docker-login.1.md +++ b/man/docker-login.1.md @@ -20,7 +20,7 @@ do not specify a `SERVER`, the command uses Docker's public registry located at `docker login` requires user to use `sudo` or be `root`, except when: 1. connecting to a remote daemon, such as a `docker-machine` provisioned `docker engine`. -2. user is added to the `docker` group. This will impact the security of your system; the `docker` group is `root` equivalent. See [Docker Daemon Attack Surface](https://docs.docker.com/articles/security/#docker-daemon-attack-surface) for details. +2. user is added to the `docker` group. This will impact the security of your system; the `docker` group is `root` equivalent. See [Docker Daemon Attack Surface](https://docs.docker.com/engine/articles/security/#docker-daemon-attack-surface) for details. You can log into any public or private repository for which you have credentials. When you log in, the command stores encoded credentials in diff --git a/man/docker-pause.1.md b/man/docker-pause.1.md index ffc3b35ca02df830e8dbe899caf6d50200911e2d..1f7d81e749a26a069933cbdb6e2693455f88a168 100644 --- a/man/docker-pause.1.md +++ b/man/docker-pause.1.md @@ -18,7 +18,7 @@ that it is being suspended, and subsequently resumed. On Windows, only Hyper-V containers can be paused. See the [cgroups freezer documentation] -(https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt) for +(https://www.kernel.org/doc/Documentation/cgroup-v1/freezer-subsystem.txt) for further details. # OPTIONS diff --git a/man/docker-run.1.md b/man/docker-run.1.md index 061f509c276e6dec13d9b9114e14c2617f880a5b..a0cbd2ba630d3f3cf4a522cefe75bc23d1fc4673 100644 --- a/man/docker-run.1.md +++ b/man/docker-run.1.md @@ -58,7 +58,6 @@ docker-run - Run a command in a new container [**--memory-reservation**[=*MEMORY-RESERVATION*]] [**--memory-swap**[=*LIMIT*]] [**--memory-swappiness**[=*MEMORY-SWAPPINESS*]] -[**--mount**[=*MOUNT*]] [**--name**[=*NAME*]] [**--network-alias**[=*[]*]] [**--network**[=*"bridge"*]] diff --git a/man/docker-unpause.1.md b/man/docker-unpause.1.md index 8c64e68de6a8e64b6a0d7af765dd2794d162bbe4..f1ea14bbe2bca030735c2031b739ba1719e98fa3 100644 --- a/man/docker-unpause.1.md +++ b/man/docker-unpause.1.md @@ -14,7 +14,7 @@ The `docker unpause` command un-suspends all processes in a container. On Linux, it does this using the cgroups freezer. See the [cgroups freezer documentation] -(https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt) for +(https://www.kernel.org/doc/Documentation/cgroup-v1/freezer-subsystem.txt) for further details. # OPTIONS diff --git a/man/docker-version.1.md b/man/docker-version.1.md index bb521c4eed6cc59061c9ab5f1abbe9a580437789..1838f820521bf9a86ef7463b9d3f17f2cbe15dc9 100644 --- a/man/docker-version.1.md +++ b/man/docker-version.1.md @@ -59,4 +59,4 @@ To view all available fields, you can use the format `{{json .}}`. # HISTORY June 2014, updated by Sven Dowideit June 2015, updated by John Howard -June 2015, updated by Patrick Hemmer diff --git a/pkg/graphdb/conn_sqlite3.go b/pkg/graphdb/conn_sqlite3_linux.go similarity index 75% rename from pkg/graphdb/conn_sqlite3.go rename to pkg/graphdb/conn_sqlite3_linux.go index dbcf44c256840d23262e71b1258988cc200c21e8..8e61ff3b4fd44c2ded00093d02f0b93bcd93434e 100644 --- a/pkg/graphdb/conn_sqlite3.go +++ b/pkg/graphdb/conn_sqlite3_linux.go @@ -2,7 +2,11 @@ package graphdb -import "database/sql" +import ( + "database/sql" + + _ "github.com/mattn/go-sqlite3" // registers sqlite +) // NewSqliteConn opens a connection to a sqlite // database. diff --git a/pkg/graphdb/conn_sqlite3_unix.go b/pkg/graphdb/conn_sqlite3_unix.go deleted file mode 100644 index f932fff2867ed9476817c6580b857d2df93736ea..0000000000000000000000000000000000000000 --- a/pkg/graphdb/conn_sqlite3_unix.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build cgo,!windows - -package graphdb - -import ( - _ "github.com/mattn/go-sqlite3" // registers sqlite -) diff --git a/pkg/graphdb/conn_sqlite3_windows.go b/pkg/graphdb/conn_sqlite3_windows.go deleted file mode 100644 index 52590303d418382cc6f9782f5ab364a16c0b3c86..0000000000000000000000000000000000000000 --- a/pkg/graphdb/conn_sqlite3_windows.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build cgo,windows - -package graphdb - -import ( - _ "github.com/mattn/go-sqlite3" // registers sqlite -) diff --git a/pkg/graphdb/conn_unsupported.go b/pkg/graphdb/conn_unsupported.go deleted file mode 100644 index cf977050dad2cef2b1bb5b062b0a14b9c40658ae..0000000000000000000000000000000000000000 --- a/pkg/graphdb/conn_unsupported.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build !cgo - -package graphdb - -// NewSqliteConn return a new sqlite connection. -func NewSqliteConn(root string) (*Database, error) { - panic("Not implemented") -} diff --git a/pkg/graphdb/graphdb.go b/pkg/graphdb/graphdb_linux.go similarity index 100% rename from pkg/graphdb/graphdb.go rename to pkg/graphdb/graphdb_linux.go diff --git a/pkg/graphdb/graphdb_test.go b/pkg/graphdb/graphdb_linux_test.go similarity index 100% rename from pkg/graphdb/graphdb_test.go rename to pkg/graphdb/graphdb_linux_test.go diff --git a/pkg/graphdb/sort.go b/pkg/graphdb/sort_linux.go similarity index 100% rename from pkg/graphdb/sort.go rename to pkg/graphdb/sort_linux.go diff --git a/pkg/graphdb/sort_test.go b/pkg/graphdb/sort_linux_test.go similarity index 100% rename from pkg/graphdb/sort_test.go rename to pkg/graphdb/sort_linux_test.go diff --git a/pkg/graphdb/unsupported.go b/pkg/graphdb/unsupported.go new file mode 100644 index 0000000000000000000000000000000000000000..2b8ba7172418ab66cd06a5893b70fb4b47ed1bc9 --- /dev/null +++ b/pkg/graphdb/unsupported.go @@ -0,0 +1,3 @@ +// +build !cgo !linux + +package graphdb diff --git a/pkg/graphdb/utils.go b/pkg/graphdb/utils_linux.go similarity index 100% rename from pkg/graphdb/utils.go rename to pkg/graphdb/utils_linux.go diff --git a/pkg/namesgenerator/names-generator.go b/pkg/namesgenerator/names-generator.go index 57e48c4f8c8024bf13b82ab3d8297c324b125b8f..cfb8157d697eb21c86c70decc16334dc89b1c293 100644 --- a/pkg/namesgenerator/names-generator.go +++ b/pkg/namesgenerator/names-generator.go @@ -15,68 +15,91 @@ var ( "amazing", "angry", "awesome", - "backstabbing", - "berserk", - "big", + "blissful", "boring", + "brave", "clever", "cocky", "compassionate", + "competent", "condescending", + "confident", "cranky", - "desperate", + "dazzling", "determined", "distracted", "dreamy", - "drunk", "eager", "ecstatic", "elastic", "elated", "elegant", - "evil", + "eloquent", + "epic", "fervent", + "festive", + "flamboyant", "focused", - "furious", - "gigantic", - "gloomy", + "friendly", + "frosty", + "gallant", + "gifted", "goofy", - "grave", + "gracious", "happy", - "high", + "hardcore", + "heuristic", "hopeful", "hungry", "infallible", + "inspiring", "jolly", "jovial", + "keen", "kickass", - "lonely", + "kind", + "laughing", "loving", - "mad", + "lucid", + "mystifying", "modest", + "musing", "naughty", - "nauseous", + "nervous", + "nifty", "nostalgic", + "objective", + "optimistic", "peaceful", "pedantic", "pensive", - "prickly", + "practical", + "priceless", + "quirky", + "quizzical", + "relaxed", "reverent", "romantic", "sad", "serene", "sharp", - "sick", "silly", "sleepy", - "small", "stoic", "stupefied", "suspicious", "tender", "thirsty", - "tiny", "trusting", + "unruffled", + "upbeat", + "vibrant", + "vigilant", + "wizardly", + "wonderful", + "xenodochial", + "youthful", + "zealous", "zen", } diff --git a/pkg/signal/trap.go b/pkg/signal/trap.go index 44c578aef53dbc4914a81dabae10a8af42e45cb5..638a1ab66c50be0229dc60be5ed1dc611e75b73f 100644 --- a/pkg/signal/trap.go +++ b/pkg/signal/trap.go @@ -83,15 +83,21 @@ func DumpStacks(dir string) (string, error) { bufferLen *= 2 } buf = buf[:stackSize] - path := filepath.Join(dir, fmt.Sprintf(stacksLogNameTemplate, strings.Replace(time.Now().Format(time.RFC3339), ":", "", -1))) - f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0666) - if err != nil { - return "", errors.Wrap(err, "failed to open file to write the goroutine stacks") + var f *os.File + if dir != "" { + path := filepath.Join(dir, fmt.Sprintf(stacksLogNameTemplate, strings.Replace(time.Now().Format(time.RFC3339), ":", "", -1))) + var err error + f, err = os.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0666) + if err != nil { + return "", errors.Wrap(err, "failed to open file to write the goroutine stacks") + } + defer f.Close() + defer f.Sync() + } else { + f = os.Stderr } - defer f.Close() if _, err := f.Write(buf); err != nil { return "", errors.Wrap(err, "failed to write goroutine stacks") } - f.Sync() - return path, nil + return f.Name(), nil } diff --git a/plugin/backend_linux.go b/plugin/backend_linux.go index d40dd83e061ffedd89703ba65d9f2500e1f09a96..8c1a152d9b003d29962994e65957931182e84062 100644 --- a/plugin/backend_linux.go +++ b/plugin/backend_linux.go @@ -11,6 +11,7 @@ import ( "net/http" "os" "path/filepath" + "regexp" "github.com/Sirupsen/logrus" "github.com/docker/docker/api/types" @@ -23,6 +24,11 @@ import ( "golang.org/x/net/context" ) +var ( + validFullID = regexp.MustCompile(`^([a-f0-9]{64})$`) + validPartialID = regexp.MustCompile(`^([a-f0-9]{1,64})$`) +) + // Disable deactivates a plugin, which implies that they cannot be used by containers. func (pm *Manager) Disable(name string) error { p, err := pm.pluginStore.GetByName(name) @@ -53,12 +59,32 @@ func (pm *Manager) Enable(name string, config *types.PluginEnableConfig) error { } // Inspect examines a plugin config -func (pm *Manager) Inspect(name string) (tp types.Plugin, err error) { - p, err := pm.pluginStore.GetByName(name) - if err != nil { +func (pm *Manager) Inspect(refOrID string) (tp types.Plugin, err error) { + // Match on full ID + if validFullID.MatchString(refOrID) { + p, err := pm.pluginStore.GetByID(refOrID) + if err == nil { + return p.PluginObj, nil + } + } + + // Match on full name + if pluginName, err := getPluginName(refOrID); err == nil { + if p, err := pm.pluginStore.GetByName(pluginName); err == nil { + return p.PluginObj, nil + } + } + + // Match on partial ID + if validPartialID.MatchString(refOrID) { + p, err := pm.pluginStore.Search(refOrID) + if err == nil { + return p.PluginObj, nil + } return tp, err } - return p.PluginObj, nil + + return tp, fmt.Errorf("no plugin name or ID associated with %q", refOrID) } func (pm *Manager) pull(ref reference.Named, metaHeader http.Header, authConfig *types.AuthConfig, pluginID string) (types.PluginPrivileges, error) { @@ -244,3 +270,18 @@ func (pm *Manager) createFromContext(ctx context.Context, pluginID, pluginDir st return nil } + +func getPluginName(name string) (string, error) { + named, err := reference.ParseNamed(name) // FIXME: validate + if err != nil { + return "", err + } + if reference.IsNameOnly(named) { + named = reference.WithDefaultTag(named) + } + ref, ok := named.(reference.NamedTagged) + if !ok { + return "", fmt.Errorf("invalid name: %s", named.String()) + } + return ref.String(), nil +} diff --git a/plugin/store/store.go b/plugin/store/store.go index fe834dc4d7fab1a513c649b996165a7075b3b96f..0517f8f2c744726cacf4e0ad361b9727e6baaa63 100644 --- a/plugin/store/store.go +++ b/plugin/store/store.go @@ -30,6 +30,13 @@ type ErrNotFound string func (name ErrNotFound) Error() string { return fmt.Sprintf("plugin %q not found", string(name)) } +// ErrAmbiguous indicates that a plugin was not found locally. +type ErrAmbiguous string + +func (name ErrAmbiguous) Error() string { + return fmt.Sprintf("multiple plugins found for %q", string(name)) +} + // GetByName retreives a plugin by name. func (ps *Store) GetByName(name string) (*v2.Plugin, error) { ps.RLock() @@ -253,3 +260,25 @@ func (ps *Store) CallHandler(p *v2.Plugin) { } } } + +// Search retreives a plugin by ID Prefix +// If no plugin is found, then ErrNotFound is returned +// If multiple plugins are found, then ErrAmbiguous is returned +func (ps *Store) Search(partialID string) (*v2.Plugin, error) { + ps.RLock() + defer ps.RUnlock() + + var found *v2.Plugin + for id, p := range ps.plugins { + if strings.HasPrefix(id, partialID) { + if found != nil { + return nil, ErrAmbiguous(partialID) + } + found = p + } + } + if found == nil { + return nil, ErrNotFound(partialID) + } + return found, nil +} diff --git a/runconfig/opts/parse.go b/runconfig/opts/parse.go index b9631f1a3e1b845bfef9d0924fab10ff932123eb..c3aa6e98b187c911b067f252a1b2be20130ed5a8 100644 --- a/runconfig/opts/parse.go +++ b/runconfig/opts/parse.go @@ -25,7 +25,6 @@ type ContainerOptions struct { attach opts.ListOpts volumes opts.ListOpts tmpfs opts.ListOpts - mounts opts.MountOpt blkioWeightDevice WeightdeviceOpt deviceReadBps ThrottledeviceOpt deviceWriteBps ThrottledeviceOpt @@ -217,7 +216,6 @@ func AddFlags(flags *pflag.FlagSet) *ContainerOptions { flags.Var(&copts.tmpfs, "tmpfs", "Mount a tmpfs directory") flags.Var(&copts.volumesFrom, "volumes-from", "Mount volumes from the specified container(s)") flags.VarP(&copts.volumes, "volume", "v", "Bind mount a volume") - flags.Var(&copts.mounts, "mount", "Attach a filesystem mount to the container") // Health-checking flags.StringVar(&copts.healthCmd, "health-cmd", "", "Command to run to check health") @@ -357,8 +355,6 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c } } - mounts := copts.mounts.Value() - var binds []string volumes := copts.volumes.GetMap() // add any bind targets to the list of container volumes @@ -623,7 +619,6 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c Tmpfs: tmpfs, Sysctls: copts.sysctls.GetAll(), Runtime: copts.runtime, - Mounts: mounts, } // only set this value if the user provided the flag, else it should default to nil