mirror of
https://github.com/docker/cli.git
synced 2026-11-13 08:13:40 -04:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98fdcd769b | ||
|
|
fb6ae356c7 | ||
|
|
1d7dd91593 | ||
|
|
de93c9b260 | ||
|
|
75f2669d56 | ||
|
|
46615e8724 | ||
|
|
cafdcf283e | ||
|
|
3768143c2e | ||
|
|
59e9fbd497 | ||
|
|
52ac1a974c | ||
|
|
f25ae85b8e | ||
|
|
58f37f630c |
@@ -23,6 +23,7 @@ type Metadata struct {
|
|||||||
// URL is a pointer to the plugin's homepage.
|
// URL is a pointer to the plugin's homepage.
|
||||||
URL string `json:",omitempty"`
|
URL string `json:",omitempty"`
|
||||||
// Experimental specifies whether the plugin is experimental.
|
// Experimental specifies whether the plugin is experimental.
|
||||||
|
//
|
||||||
// Deprecated: experimental features are now always enabled in the CLI
|
// Deprecated: experimental features are now always enabled in the CLI
|
||||||
Experimental bool `json:",omitempty"`
|
Experimental bool `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func (o *ClientOptions) InstallFlags(flags *pflag.FlagSet) {
|
|||||||
|
|
||||||
// opts.ValidateHost is not used here, so as to allow connection helpers
|
// opts.ValidateHost is not used here, so as to allow connection helpers
|
||||||
hostOpt := opts.NewNamedListOptsRef("hosts", &o.Hosts, nil)
|
hostOpt := opts.NewNamedListOptsRef("hosts", &o.Hosts, nil)
|
||||||
flags.VarP(hostOpt, "host", "H", "Daemon socket(s) to connect to")
|
flags.VarP(hostOpt, "host", "H", "Daemon socket to connect to")
|
||||||
flags.StringVarP(&o.Context, "context", "c", "",
|
flags.StringVarP(&o.Context, "context", "c", "",
|
||||||
`Name of the context to use to connect to the daemon (overrides `+client.EnvOverrideHost+` env var and default context set with "docker context use")`)
|
`Name of the context to use to connect to the daemon (overrides `+client.EnvOverrideHost+` env var and default context set with "docker context use")`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,18 +92,18 @@ The base command for the Docker CLI.
|
|||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:--------------------|:---------|:-------------------------|:--------------------------------------------------------------------------------------------------------------------------------------|
|
|:---------------------------------|:---------|:-------------------------|:--------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `--config` | `string` | `/root/.docker` | Location of client config files |
|
| `--config` | `string` | `/root/.docker` | Location of client config files |
|
||||||
| `-c`, `--context` | `string` | | Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with `docker context use`) |
|
| `-c`, `--context` | `string` | | Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with `docker context use`) |
|
||||||
| `-D`, `--debug` | | | Enable debug mode |
|
| `-D`, `--debug` | | | Enable debug mode |
|
||||||
| `-H`, `--host` | `list` | | Daemon socket(s) to connect to |
|
| [`-H`](#host), [`--host`](#host) | `list` | | Daemon socket to connect to |
|
||||||
| `-l`, `--log-level` | `string` | `info` | Set the logging level (`debug`, `info`, `warn`, `error`, `fatal`) |
|
| `-l`, `--log-level` | `string` | `info` | Set the logging level (`debug`, `info`, `warn`, `error`, `fatal`) |
|
||||||
| `--tls` | | | Use TLS; implied by --tlsverify |
|
| `--tls` | | | Use TLS; implied by --tlsverify |
|
||||||
| `--tlscacert` | `string` | `/root/.docker/ca.pem` | Trust certs signed only by this CA |
|
| `--tlscacert` | `string` | `/root/.docker/ca.pem` | Trust certs signed only by this CA |
|
||||||
| `--tlscert` | `string` | `/root/.docker/cert.pem` | Path to TLS certificate file |
|
| `--tlscert` | `string` | `/root/.docker/cert.pem` | Path to TLS certificate file |
|
||||||
| `--tlskey` | `string` | `/root/.docker/key.pem` | Path to TLS key file |
|
| `--tlskey` | `string` | `/root/.docker/key.pem` | Path to TLS key file |
|
||||||
| `--tlsverify` | | | Use TLS and verify the remote |
|
| `--tlsverify` | | | Use TLS and verify the remote |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
@@ -378,6 +378,56 @@ list of root Certificate Authorities.
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
### <a name="host"></a> Specify daemon host (-H, --host)
|
||||||
|
|
||||||
|
You can use the `-H`, `--host` flag to specify a socket to use when you invoke
|
||||||
|
a `docker` command. You can use the following protocols:
|
||||||
|
|
||||||
|
| Scheme | Description | Example |
|
||||||
|
|----------------------------------------|---------------------------|----------------------------------|
|
||||||
|
| `unix://[<path>]` | Unix socket (Linux only) | `unix:///var/run/docker.sock` |
|
||||||
|
| `tcp://[<IP or host>[:port]]` | TCP connection | `tcp://174.17.0.1:2376` |
|
||||||
|
| `ssh://[username@]<IP or host>[:port]` | SSH connection | `ssh://user@192.168.64.5` |
|
||||||
|
| `npipe://[<name>]` | Named pipe (Windows only) | `npipe:////./pipe/docker_engine` |
|
||||||
|
|
||||||
|
If you don't specify the `-H` flag, and you're not using a custom
|
||||||
|
[context](https://docs.docker.com/engine/context/working-with-contexts),
|
||||||
|
commands use the following default sockets:
|
||||||
|
|
||||||
|
- `unix:///var/run/docker.sock` on macOS and Linux
|
||||||
|
- `npipe:////./pipe/docker_engine` on Windows
|
||||||
|
|
||||||
|
To achieve a similar effect without having to specify the `-H` flag for every
|
||||||
|
command, you could also [create a context](context_create.md),
|
||||||
|
or alternatively, use the
|
||||||
|
[`DOCKER_HOST` environment variable](#environment-variables).
|
||||||
|
|
||||||
|
For more information about the `-H` flag, see
|
||||||
|
[Daemon socket option](dockerd.md#daemon-socket-option).
|
||||||
|
|
||||||
|
#### Using TCP sockets
|
||||||
|
|
||||||
|
The following example shows how to invoke `docker ps` over TCP, to a remote
|
||||||
|
daemon with IP address `174.17.0.1`, listening on port `2376`:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker -H tcp://174.17.0.1:2376 ps
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note**
|
||||||
|
>
|
||||||
|
> By convention, the Docker daemon uses port `2376` for secure TLS connections,
|
||||||
|
> and port `2375` for insecure, non-TLS connections.
|
||||||
|
|
||||||
|
#### Using SSH sockets
|
||||||
|
|
||||||
|
When you use SSH invoke a command on a remote daemon, the request gets forwarded
|
||||||
|
to the `/var/run/docker.sock` Unix socket on the SSH host.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker -H ssh://user@192.168.64.5 ps
|
||||||
|
```
|
||||||
|
|
||||||
### Display help text
|
### Display help text
|
||||||
|
|
||||||
To list the help on any command just execute the command, followed by the
|
To list the help on any command just execute the command, followed by the
|
||||||
|
|||||||
@@ -12,27 +12,45 @@ Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
|
|||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
An image name is made up of slash-separated name components, optionally prefixed
|
A full image name has the following format and components:
|
||||||
by a registry hostname. The hostname must comply with standard DNS rules, but
|
|
||||||
may not contain underscores. If a hostname is present, it may optionally be
|
|
||||||
followed by a port number in the format `:8080`. If not present, the command
|
|
||||||
uses Docker's public registry located at `registry-1.docker.io` by default. Name
|
|
||||||
components may contain lowercase letters, digits and separators. A separator
|
|
||||||
is defined as a period, one or two underscores, or one or more hyphens. A name
|
|
||||||
component may not start or end with a separator.
|
|
||||||
|
|
||||||
A tag name must be valid ASCII and may contain lowercase and uppercase letters,
|
`[HOST[:PORT_NUMBER]/]PATH`
|
||||||
digits, underscores, periods and hyphens. A tag name may not start with a
|
|
||||||
period or a hyphen and may contain a maximum of 128 characters.
|
|
||||||
|
|
||||||
You can group your images together using names and tags, and then upload them
|
- `HOST`: The optional registry hostname specifies where the image is located.
|
||||||
to [*Share images on Docker Hub*](https://docs.docker.com/get-started/part3/).
|
The hostname must comply with standard DNS rules, but may not contain
|
||||||
|
underscores. If the hostname is not specified, the command uses Docker's public
|
||||||
|
registry at `registry-1.docker.io` by default. Note that `docker.io` is the
|
||||||
|
canonical reference for Docker's public registry.
|
||||||
|
- `PORT_NUMBER`: If a hostname is present, it may optionally be followed by a
|
||||||
|
registry port number in the format `:8080`.
|
||||||
|
- `PATH`: The path consists consists of slash-separated components. Each
|
||||||
|
component may contain lowercase letters, digits and separators. A separator is
|
||||||
|
defined as a period, one or two underscores, or one or more hyphens. A component
|
||||||
|
may not start or end with a separator. While the
|
||||||
|
[OCI Distribution Specification](https://github.com/opencontainers/distribution-spec)
|
||||||
|
supports more than two slash-separated components, most registries only support
|
||||||
|
two slash-separated components. For Docker's public registry, the path format is
|
||||||
|
as follows:
|
||||||
|
- `[NAMESPACE/]REPOSITORY`: The first, optional component is typically a
|
||||||
|
user's or an organization's namespace. The second, mandatory component is the
|
||||||
|
repository name. When the namespace is not present, Docker uses `library`
|
||||||
|
as the default namespace.
|
||||||
|
|
||||||
|
After the image name, the optional `TAG` is a custom, human-readable manifest
|
||||||
|
identifier that is typically a specific version or variant of an image. The tag
|
||||||
|
must be valid ASCII and can contain lowercase and uppercase letters, digits,
|
||||||
|
underscores, periods, and hyphens. It cannot start with a period or hyphen and
|
||||||
|
must be no longer than 128 characters. If the tag is not specified, the command uses `latest` by default.
|
||||||
|
|
||||||
|
You can group your images together using names and tags, and then
|
||||||
|
[push](https://docs.docker.com/engine/reference/commandline/push) them to a
|
||||||
|
registry.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Tag an image referenced by ID
|
### Tag an image referenced by ID
|
||||||
|
|
||||||
To tag a local image with ID "0e5574283393" into the "fedora" repository with
|
To tag a local image with ID "0e5574283393" as "fedora/httpd" with the tag
|
||||||
"version1.0":
|
"version1.0":
|
||||||
|
|
||||||
```console
|
```console
|
||||||
@@ -41,8 +59,7 @@ $ docker tag 0e5574283393 fedora/httpd:version1.0
|
|||||||
|
|
||||||
### Tag an image referenced by Name
|
### Tag an image referenced by Name
|
||||||
|
|
||||||
To tag a local image with name "httpd" into the "fedora" repository with
|
To tag a local image "httpd" as "fedora/httpd" with the tag "version1.0":
|
||||||
"version1.0":
|
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ docker tag httpd fedora/httpd:version1.0
|
$ docker tag httpd fedora/httpd:version1.0
|
||||||
@@ -53,17 +70,17 @@ existing local version `httpd:latest`.
|
|||||||
|
|
||||||
### Tag an image referenced by Name and Tag
|
### Tag an image referenced by Name and Tag
|
||||||
|
|
||||||
To tag a local image with name "httpd" and tag "test" into the "fedora"
|
To tag a local image with the name "httpd" and the tag "test" as "fedora/httpd"
|
||||||
repository with "version1.0.test":
|
with the tag "version1.0.test":
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ docker tag httpd:test fedora/httpd:version1.0.test
|
$ docker tag httpd:test fedora/httpd:version1.0.test
|
||||||
```
|
```
|
||||||
|
|
||||||
### Tag an image for a private repository
|
### Tag an image for a private registry
|
||||||
|
|
||||||
To push an image to a private registry and not the central Docker
|
To push an image to a private registry and not the public Docker registry you
|
||||||
registry you must tag it with the registry hostname and port (if needed).
|
must include the registry hostname and port (if needed).
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ docker tag 0e5574283393 myregistryhost:5000/fedora/httpd:version1.0
|
$ docker tag 0e5574283393 myregistryhost:5000/fedora/httpd:version1.0
|
||||||
|
|||||||
+2
-2
@@ -9,8 +9,8 @@ go 1.18
|
|||||||
require (
|
require (
|
||||||
github.com/containerd/containerd v1.6.21
|
github.com/containerd/containerd v1.6.21
|
||||||
github.com/creack/pty v1.1.18
|
github.com/creack/pty v1.1.18
|
||||||
github.com/docker/distribution v2.8.1+incompatible
|
github.com/docker/distribution v2.8.2+incompatible
|
||||||
github.com/docker/docker v24.0.0-rc.1.0.20230505222407-8d9a40a82034+incompatible
|
github.com/docker/docker v24.0.0-rc.3+incompatible
|
||||||
github.com/docker/docker-credential-helpers v0.7.0
|
github.com/docker/docker-credential-helpers v0.7.0
|
||||||
github.com/docker/go-connections v0.4.0
|
github.com/docker/go-connections v0.4.0
|
||||||
github.com/docker/go-units v0.5.0
|
github.com/docker/go-units v0.5.0
|
||||||
|
|||||||
+4
-4
@@ -94,10 +94,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||||
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||||
github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
|
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
|
||||||
github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||||
github.com/docker/docker v24.0.0-rc.1.0.20230505222407-8d9a40a82034+incompatible h1:Y2oMmZDlVZhIkKzBUCeY48pi8ophHyEAoW04ABKn3DU=
|
github.com/docker/docker v24.0.0-rc.3+incompatible h1:DvPU6bHqKAXC9J81HHebUPSgXEr/g0Mv84SuVPEe8TI=
|
||||||
github.com/docker/docker v24.0.0-rc.1.0.20230505222407-8d9a40a82034+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
github.com/docker/docker v24.0.0-rc.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||||
github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A=
|
github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A=
|
||||||
github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0=
|
github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0=
|
||||||
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
|
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
bin/
|
||||||
+7
@@ -18,3 +18,10 @@ run:
|
|||||||
deadline: 2m
|
deadline: 2m
|
||||||
skip-dirs:
|
skip-dirs:
|
||||||
- vendor
|
- vendor
|
||||||
|
|
||||||
|
issues:
|
||||||
|
exclude-rules:
|
||||||
|
# io/ioutil is deprecated, but won't be removed until Go v2. It's safe to ignore for the release/2.8 branch.
|
||||||
|
- text: "SA1019: \"io/ioutil\" has been deprecated since Go 1.16"
|
||||||
|
linters:
|
||||||
|
- staticcheck
|
||||||
|
|||||||
+4
-2
@@ -44,6 +44,8 @@ Thomas Berger <loki@lokis-chaos.de> Thomas Berger <tbe@users.noreply.github.com>
|
|||||||
Samuel Karp <skarp@amazon.com> Samuel Karp <samuelkarp@users.noreply.github.com>
|
Samuel Karp <skarp@amazon.com> Samuel Karp <samuelkarp@users.noreply.github.com>
|
||||||
Justin Cormack <justin.cormack@docker.com>
|
Justin Cormack <justin.cormack@docker.com>
|
||||||
sayboras <sayboras@yahoo.com>
|
sayboras <sayboras@yahoo.com>
|
||||||
CrazyMax <github@crazymax.dev>
|
|
||||||
CrazyMax <github@crazymax.dev> <1951866+crazy-max@users.noreply.github.com>
|
CrazyMax <github@crazymax.dev> <1951866+crazy-max@users.noreply.github.com>
|
||||||
CrazyMax <github@crazymax.dev> <crazy-max@users.noreply.github.com>
|
Hayley Swimelar <hswimelar@gmail.com>
|
||||||
|
Jose D. Gomez R <jose.gomez@suse.com>
|
||||||
|
Shengjing Zhu <zhsj@debian.org>
|
||||||
|
Silvin Lubecki <31478878+silvin-lubecki@users.noreply.github.com>
|
||||||
|
|||||||
+46
-36
@@ -1,49 +1,59 @@
|
|||||||
# syntax=docker/dockerfile:1.3
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
ARG GO_VERSION=1.16.15
|
ARG GO_VERSION=1.19.9
|
||||||
ARG GORELEASER_XX_VERSION=1.2.5
|
ARG ALPINE_VERSION=3.16
|
||||||
|
ARG XX_VERSION=1.2.1
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM crazymax/goreleaser-xx:${GORELEASER_XX_VERSION} AS goreleaser-xx
|
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
||||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS base
|
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
|
||||||
COPY --from=goreleaser-xx / /
|
COPY --from=xx / /
|
||||||
RUN apk add --no-cache file git
|
RUN apk add --no-cache bash coreutils file git
|
||||||
WORKDIR /go/src/github.com/docker/distribution
|
|
||||||
|
|
||||||
FROM base AS build
|
|
||||||
ENV GO111MODULE=auto
|
ENV GO111MODULE=auto
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
# GIT_REF is used by goreleaser-xx to handle the proper git ref when available.
|
WORKDIR /go/src/github.com/docker/distribution
|
||||||
# It will fallback to the working tree info if empty and use "git tag --points-at"
|
|
||||||
# or "git describe" to define the version info.
|
|
||||||
ARG GIT_REF
|
|
||||||
ARG TARGETPLATFORM
|
|
||||||
ARG PKG="github.com/distribution/distribution"
|
|
||||||
ARG BUILDTAGS="include_oss include_gcs"
|
|
||||||
RUN --mount=type=bind,rw \
|
|
||||||
--mount=type=cache,target=/root/.cache/go-build \
|
|
||||||
--mount=target=/go/pkg/mod,type=cache \
|
|
||||||
goreleaser-xx --debug \
|
|
||||||
--name="registry" \
|
|
||||||
--dist="/out" \
|
|
||||||
--main="./cmd/registry" \
|
|
||||||
--flags="-v" \
|
|
||||||
--ldflags="-s -w -X '$PKG/version.Version={{.Version}}' -X '$PKG/version.Revision={{.Commit}}' -X '$PKG/version.Package=$PKG'" \
|
|
||||||
--tags="$BUILDTAGS" \
|
|
||||||
--files="LICENSE" \
|
|
||||||
--files="README.md"
|
|
||||||
|
|
||||||
FROM scratch AS artifact
|
FROM base AS version
|
||||||
COPY --from=build /out/*.tar.gz /
|
ARG PKG="github.com/docker/distribution"
|
||||||
COPY --from=build /out/*.zip /
|
RUN --mount=target=. \
|
||||||
COPY --from=build /out/*.sha256 /
|
VERSION=$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags) REVISION=$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi); \
|
||||||
|
echo "-X ${PKG}/version.Version=${VERSION#v} -X ${PKG}/version.Revision=${REVISION} -X ${PKG}/version.Package=${PKG}" | tee /tmp/.ldflags; \
|
||||||
|
echo -n "${VERSION}" | tee /tmp/.version;
|
||||||
|
|
||||||
|
FROM base AS build
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
ARG LDFLAGS="-s -w"
|
||||||
|
ARG BUILDTAGS="include_oss include_gcs"
|
||||||
|
RUN --mount=type=bind,target=/go/src/github.com/docker/distribution,rw \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
--mount=target=/go/pkg/mod,type=cache \
|
||||||
|
--mount=type=bind,source=/tmp/.ldflags,target=/tmp/.ldflags,from=version \
|
||||||
|
set -x ; xx-go build -trimpath -ldflags "$(cat /tmp/.ldflags) ${LDFLAGS}" -o /usr/bin/registry ./cmd/registry \
|
||||||
|
&& xx-verify --static /usr/bin/registry
|
||||||
|
|
||||||
FROM scratch AS binary
|
FROM scratch AS binary
|
||||||
COPY --from=build /usr/local/bin/registry* /
|
COPY --from=build /usr/bin/registry /
|
||||||
|
|
||||||
FROM alpine:3.14
|
FROM base AS releaser
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
ARG TARGETVARIANT
|
||||||
|
WORKDIR /work
|
||||||
|
RUN --mount=from=binary,target=/build \
|
||||||
|
--mount=type=bind,target=/src \
|
||||||
|
--mount=type=bind,source=/tmp/.version,target=/tmp/.version,from=version \
|
||||||
|
VERSION=$(cat /tmp/.version) \
|
||||||
|
&& mkdir -p /out \
|
||||||
|
&& cp /build/registry /src/README.md /src/LICENSE . \
|
||||||
|
&& tar -czvf "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.gz" * \
|
||||||
|
&& sha256sum -z "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.gz" | awk '{ print $1 }' > "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.gz.sha256"
|
||||||
|
|
||||||
|
FROM scratch AS artifact
|
||||||
|
COPY --from=releaser /out /
|
||||||
|
|
||||||
|
FROM alpine:${ALPINE_VERSION}
|
||||||
RUN apk add --no-cache ca-certificates
|
RUN apk add --no-cache ca-certificates
|
||||||
COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml
|
COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml
|
||||||
COPY --from=build /usr/local/bin/registry /bin/registry
|
COPY --from=binary /registry /bin/registry
|
||||||
VOLUME ["/var/lib/registry"]
|
VOLUME ["/var/lib/registry"]
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
ENTRYPOINT ["registry"]
|
ENTRYPOINT ["registry"]
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@ version/version.go:
|
|||||||
|
|
||||||
check: ## run all linters (TODO: enable "unused", "varcheck", "ineffassign", "unconvert", "staticheck", "goimports", "structcheck")
|
check: ## run all linters (TODO: enable "unused", "varcheck", "ineffassign", "unconvert", "staticheck", "goimports", "structcheck")
|
||||||
@echo "$(WHALE) $@"
|
@echo "$(WHALE) $@"
|
||||||
golangci-lint run
|
@GO111MODULE=off golangci-lint run
|
||||||
|
|
||||||
test: ## run tests, except integration test with test.short
|
test: ## run tests, except integration test with test.short
|
||||||
@echo "$(WHALE) $@"
|
@echo "$(WHALE) $@"
|
||||||
|
|||||||
+6
-15
@@ -1,15 +1,3 @@
|
|||||||
// GITHUB_REF is the actual ref that triggers the workflow
|
|
||||||
// https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
|
||||||
variable "GITHUB_REF" {
|
|
||||||
default = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
target "_common" {
|
|
||||||
args = {
|
|
||||||
GIT_REF = GITHUB_REF
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
group "default" {
|
group "default" {
|
||||||
targets = ["image-local"]
|
targets = ["image-local"]
|
||||||
}
|
}
|
||||||
@@ -20,13 +8,11 @@ target "docker-metadata-action" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
target "binary" {
|
target "binary" {
|
||||||
inherits = ["_common"]
|
|
||||||
target = "binary"
|
target = "binary"
|
||||||
output = ["./bin"]
|
output = ["./bin"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "artifact" {
|
target "artifact" {
|
||||||
inherits = ["_common"]
|
|
||||||
target = "artifact"
|
target = "artifact"
|
||||||
output = ["./bin"]
|
output = ["./bin"]
|
||||||
}
|
}
|
||||||
@@ -43,8 +29,13 @@ target "artifact-all" {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special target: https://github.com/docker/metadata-action#bake-definition
|
||||||
|
target "docker-metadata-action" {
|
||||||
|
tags = ["registry:local"]
|
||||||
|
}
|
||||||
|
|
||||||
target "image" {
|
target "image" {
|
||||||
inherits = ["_common", "docker-metadata-action"]
|
inherits = ["docker-metadata-action"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "image-local" {
|
target "image-local" {
|
||||||
|
|||||||
+2
-2
@@ -3,13 +3,13 @@
|
|||||||
//
|
//
|
||||||
// Grammar
|
// Grammar
|
||||||
//
|
//
|
||||||
// reference := name [ ":" tag ] [ "@" digest ]
|
// reference := name [ ":" tag ] [ "@" digest ]
|
||||||
// name := [domain '/'] path-component ['/' path-component]*
|
// name := [domain '/'] path-component ['/' path-component]*
|
||||||
// domain := domain-component ['.' domain-component]* [':' port-number]
|
// domain := domain-component ['.' domain-component]* [':' port-number]
|
||||||
// domain-component := /([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/
|
// domain-component := /([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/
|
||||||
// port-number := /[0-9]+/
|
// port-number := /[0-9]+/
|
||||||
// path-component := alpha-numeric [separator alpha-numeric]*
|
// path-component := alpha-numeric [separator alpha-numeric]*
|
||||||
// alpha-numeric := /[a-z0-9]+/
|
// alpha-numeric := /[a-z0-9]+/
|
||||||
// separator := /[_.]|__|[-]*/
|
// separator := /[_.]|__|[-]*/
|
||||||
//
|
//
|
||||||
// tag := /[\w][\w.-]{0,127}/
|
// tag := /[\w][\w.-]{0,127}/
|
||||||
|
|||||||
+17
@@ -134,6 +134,19 @@ var (
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invalidPaginationResponseDescriptor = ResponseDescriptor{
|
||||||
|
Name: "Invalid pagination number",
|
||||||
|
Description: "The received parameter n was invalid in some way, as described by the error code. The client should resolve the issue and retry the request.",
|
||||||
|
StatusCode: http.StatusBadRequest,
|
||||||
|
Body: BodyDescriptor{
|
||||||
|
ContentType: "application/json",
|
||||||
|
Format: errorsBody,
|
||||||
|
},
|
||||||
|
ErrorCodes: []errcode.ErrorCode{
|
||||||
|
ErrorCodePaginationNumberInvalid,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
repositoryNotFoundResponseDescriptor = ResponseDescriptor{
|
repositoryNotFoundResponseDescriptor = ResponseDescriptor{
|
||||||
Name: "No Such Repository Error",
|
Name: "No Such Repository Error",
|
||||||
StatusCode: http.StatusNotFound,
|
StatusCode: http.StatusNotFound,
|
||||||
@@ -490,6 +503,7 @@ var routeDescriptors = []RouteDescriptor{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Failures: []ResponseDescriptor{
|
Failures: []ResponseDescriptor{
|
||||||
|
invalidPaginationResponseDescriptor,
|
||||||
unauthorizedResponseDescriptor,
|
unauthorizedResponseDescriptor,
|
||||||
repositoryNotFoundResponseDescriptor,
|
repositoryNotFoundResponseDescriptor,
|
||||||
deniedResponseDescriptor,
|
deniedResponseDescriptor,
|
||||||
@@ -1578,6 +1592,9 @@ var routeDescriptors = []RouteDescriptor{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Failures: []ResponseDescriptor{
|
||||||
|
invalidPaginationResponseDescriptor,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+9
@@ -133,4 +133,13 @@ var (
|
|||||||
longer proceed.`,
|
longer proceed.`,
|
||||||
HTTPStatusCode: http.StatusNotFound,
|
HTTPStatusCode: http.StatusNotFound,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ErrorCodePaginationNumberInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
|
||||||
|
Value: "PAGINATION_NUMBER_INVALID",
|
||||||
|
Message: "invalid number of results requested",
|
||||||
|
Description: `Returned when the "n" parameter (number of results
|
||||||
|
to return) is not an integer, "n" is negative or "n" is bigger than
|
||||||
|
the maximum allowed.`,
|
||||||
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
+2
@@ -55,6 +55,8 @@ func parseHTTPErrorResponse(statusCode int, r io.Reader) error {
|
|||||||
switch statusCode {
|
switch statusCode {
|
||||||
case http.StatusUnauthorized:
|
case http.StatusUnauthorized:
|
||||||
return errcode.ErrorCodeUnauthorized.WithMessage(detailsErr.Details)
|
return errcode.ErrorCodeUnauthorized.WithMessage(detailsErr.Details)
|
||||||
|
case http.StatusForbidden:
|
||||||
|
return errcode.ErrorCodeDenied.WithMessage(detailsErr.Details)
|
||||||
case http.StatusTooManyRequests:
|
case http.StatusTooManyRequests:
|
||||||
return errcode.ErrorCodeTooManyRequests.WithMessage(detailsErr.Details)
|
return errcode.ErrorCodeTooManyRequests.WithMessage(detailsErr.Details)
|
||||||
default:
|
default:
|
||||||
|
|||||||
+1
-3
@@ -114,9 +114,7 @@ func (r *registry) Repositories(ctx context.Context, entries []string, last stri
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for cnt := range ctlg.Repositories {
|
copy(entries, ctlg.Repositories)
|
||||||
entries[cnt] = ctlg.Repositories[cnt]
|
|
||||||
}
|
|
||||||
numFilled = len(ctlg.Repositories)
|
numFilled = len(ctlg.Repositories)
|
||||||
|
|
||||||
link := resp.Header.Get("Link")
|
link := resp.Header.Get("Link")
|
||||||
|
|||||||
-1
@@ -180,7 +180,6 @@ func (hrs *httpReadSeeker) reader() (io.Reader, error) {
|
|||||||
// context.GetLogger(hrs.context).Infof("Range: %s", req.Header.Get("Range"))
|
// context.GetLogger(hrs.context).Infof("Range: %s", req.Header.Get("Range"))
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Header.Add("Accept-Encoding", "identity")
|
|
||||||
resp, err := hrs.client.Do(req)
|
resp, err := hrs.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Vendored
+2
-2
@@ -21,7 +21,7 @@ github.com/containerd/containerd/platforms
|
|||||||
# github.com/creack/pty v1.1.18
|
# github.com/creack/pty v1.1.18
|
||||||
## explicit; go 1.13
|
## explicit; go 1.13
|
||||||
github.com/creack/pty
|
github.com/creack/pty
|
||||||
# github.com/docker/distribution v2.8.1+incompatible
|
# github.com/docker/distribution v2.8.2+incompatible
|
||||||
## explicit
|
## explicit
|
||||||
github.com/docker/distribution
|
github.com/docker/distribution
|
||||||
github.com/docker/distribution/digestset
|
github.com/docker/distribution/digestset
|
||||||
@@ -40,7 +40,7 @@ github.com/docker/distribution/registry/client/transport
|
|||||||
github.com/docker/distribution/registry/storage/cache
|
github.com/docker/distribution/registry/storage/cache
|
||||||
github.com/docker/distribution/registry/storage/cache/memory
|
github.com/docker/distribution/registry/storage/cache/memory
|
||||||
github.com/docker/distribution/uuid
|
github.com/docker/distribution/uuid
|
||||||
# github.com/docker/docker v24.0.0-rc.1.0.20230505222407-8d9a40a82034+incompatible
|
# github.com/docker/docker v24.0.0-rc.3+incompatible
|
||||||
## explicit
|
## explicit
|
||||||
github.com/docker/docker/api
|
github.com/docker/docker/api
|
||||||
github.com/docker/docker/api/types
|
github.com/docker/docker/api/types
|
||||||
|
|||||||
Reference in New Issue
Block a user