Compare commits
178 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a2c30b63a | |||
| 47649fbdc5 | |||
| 3b562e9a8e | |||
| e7cdabeaba | |||
| 5106d8ed8b | |||
| ce1068236d | |||
| 058f7dfa01 | |||
| 226a2fd64e | |||
| 42eca75740 | |||
| 0c8ce43ccc | |||
| 0b421dc050 | |||
| 2d3c4056b3 | |||
| 9835d5d33a | |||
| 28b7a35187 | |||
| 9124a42b40 | |||
| 34fae412ca | |||
| a60bf813b3 | |||
| 2d4e433fad | |||
| a9d9bbf27f | |||
| acc3f991fc | |||
| baeda1f82a | |||
| 3e3677e47d | |||
| e814bd038d | |||
| 20e3951aeb | |||
| 643e2e50ae | |||
| 75d7ce92a2 | |||
| 9fdeb9c3de | |||
| a12c535f6e | |||
| d18a3e9004 | |||
| 932ca73874 | |||
| 7d51e65e72 | |||
| d85ef84533 | |||
| d1f9546dc3 | |||
| 1ea8d69d6f | |||
| e82aa85741 | |||
| e9176b36cc | |||
| a39f3fbdfd | |||
| 2fa0c6253a | |||
| bc6ff39e42 | |||
| 3fa7a8654f | |||
| 18e275c52e | |||
| 3e06ce8bfa | |||
| b40c2f6b5d | |||
| 93eead45ee | |||
| bd04f199f7 | |||
| 2484f7e046 | |||
| 45075ea08c | |||
| c2dcaecf19 | |||
| 613b9362d0 | |||
| b30d250320 | |||
| fe0cdaf027 | |||
| 6b25bc3003 | |||
| 0785bd743d | |||
| bdac0b38d9 | |||
| c70b01ec1f | |||
| 0389090aeb | |||
| c904936d69 | |||
| 386d50c2e9 | |||
| 990186f2f6 | |||
| 86bf1966e2 | |||
| b3022b91d1 | |||
| f14ba9f5d7 | |||
| ae45936575 | |||
| c189c4dbea | |||
| 0c46ffc1f9 | |||
| 6be9ce798e | |||
| c8b7ef1e29 | |||
| 779ed309a8 | |||
| 2f7e84be65 | |||
| e628209d9b | |||
| 80a3add604 | |||
| 715cfc4c2f | |||
| 80fb0d575e | |||
| 9d28e08a2d | |||
| d72bef2088 | |||
| 100c70180f | |||
| 7502d7e560 | |||
| 4d718932c1 | |||
| 826eaafa6d | |||
| 308624c3b1 | |||
| de7d866b6a | |||
| aa7e414fdc | |||
| 240e4b5501 | |||
| 5d4776bd90 | |||
| 1841277463 | |||
| 49e9c2ae3d | |||
| 87a3ce2699 | |||
| 1d8abed17d | |||
| fd82621d35 | |||
| e5ca16bda7 | |||
| 31dad66f9a | |||
| 113c5b526a | |||
| c73edb36ca | |||
| 80f673bf9e | |||
| 3d4cc8e699 | |||
| 30277a8f80 | |||
| 994ed4085b | |||
| b10a23a46f | |||
| 26d906094a | |||
| 9c091c4346 | |||
| a13500b745 | |||
| cfef3a7dc1 | |||
| 53426025c3 | |||
| 573a664639 | |||
| cf0ab7ac4c | |||
| d05fd4ffc8 | |||
| 870f138250 | |||
| 7ffc243093 | |||
| 198d6b8724 | |||
| 55a14ec851 | |||
| 1f9a0df05a | |||
| 4ae338b33a | |||
| 6380142dd4 | |||
| 82f422fcf3 | |||
| 80fd77903b | |||
| c3d4d623c8 | |||
| 2e82d11def | |||
| 738a6ee1cc | |||
| 246d96bb6c | |||
| 2fd0f17057 | |||
| 5fa500000a | |||
| 1e6a8ce2b7 | |||
| 81d965569d | |||
| 6f7a931a2d | |||
| 16169434a4 | |||
| 91bab605f7 | |||
| a224086349 | |||
| a282e0c5d2 | |||
| f3764ff5f9 | |||
| 700364e304 | |||
| 62d27c32ff | |||
| c0e952cf04 | |||
| 04104a04d3 | |||
| b721998b7b | |||
| 4065e1246e | |||
| f1002eb9fb | |||
| e97c7b240e | |||
| aa78937634 | |||
| 40fe0573aa | |||
| c9737e1c37 | |||
| 5c6723d080 | |||
| 59a8a0906f | |||
| 3f9857e6a8 | |||
| fd5fc61ecd | |||
| 3624019d83 | |||
| 96f2cf80ab | |||
| f3ff8e6ad6 | |||
| ee1ac1b319 | |||
| e91ed5707e | |||
| 38dd744a11 | |||
| cedc602a78 | |||
| 4de40a825e | |||
| dea9396e18 | |||
| 03fa8f92c8 | |||
| b485636f4b | |||
| 241523cc1a | |||
| 9989fdbc40 | |||
| 0e20c1fd21 | |||
| c4cb29837f | |||
| 0b56256638 | |||
| 1c0927a041 | |||
| 82f9d5921b | |||
| adb01ca79d | |||
| 8260476a06 | |||
| aa5b6b7728 | |||
| 859e303655 | |||
| bce2e1f953 | |||
| 44064f51c8 | |||
| 292779add5 | |||
| f2e79b826c | |||
| fa46b92361 | |||
| 400f81089a | |||
| c72057c8db | |||
| 77db97d595 | |||
| cbf0d2b7b7 | |||
| d0014a86bc | |||
| 6c1c8b55aa | |||
| 061051c24d |
@ -42,7 +42,7 @@ jobs:
|
||||
docker: [{image: 'docker:20.10-git'}]
|
||||
environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
BUILDX_VERSION: "v0.5.1"
|
||||
BUILDX_VERSION: "v0.8.2"
|
||||
parallelism: 3
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
@ -5,12 +5,10 @@ linters:
|
||||
- dogsled
|
||||
- gocyclo
|
||||
- goimports
|
||||
- golint
|
||||
- gosec
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- interfacer
|
||||
- lll
|
||||
- megacheck
|
||||
- misspell
|
||||
@ -21,6 +19,7 @@ linters:
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- revive
|
||||
- varcheck
|
||||
|
||||
disable:
|
||||
@ -54,30 +53,65 @@ issues:
|
||||
- parameter .* always receives
|
||||
|
||||
exclude-rules:
|
||||
# These are copied from the default exclude rules, except for "ineffective break statement"
|
||||
# and GoDoc checks.
|
||||
# https://github.com/golangci/golangci-lint/blob/0cc87df732aaf1d5ad9ce9ca538d38d916918b36/pkg/config/config.go#L36
|
||||
- text: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked"
|
||||
# We prefer to use an "exclude-list" so that new "default" exclusions are not
|
||||
# automatically inherited. We can decide whether or not to follow upstream
|
||||
# defaults when updating golang-ci-lint versions.
|
||||
# Unfortunately, this means we have to copy the whole exclusion pattern, as
|
||||
# (unlike the "include" option), the "exclude" option does not take exclusion
|
||||
# ID's.
|
||||
#
|
||||
# These exclusion patterns are copied from the default excluses at:
|
||||
# https://github.com/golangci/golangci-lint/blob/v1.44.0/pkg/config/issues.go#L10-L104
|
||||
|
||||
# EXC0001
|
||||
- text: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked"
|
||||
linters:
|
||||
- errcheck
|
||||
# EXC0003
|
||||
- text: "func name will be used as test\\.Test.* by other packages, and that stutters; consider calling this"
|
||||
linters:
|
||||
- golint
|
||||
- text: "G103: Use of unsafe calls should be audited"
|
||||
- revive
|
||||
# EXC0006
|
||||
- text: "Use of unsafe calls should be audited"
|
||||
linters:
|
||||
- gosec
|
||||
- text: "G104: Errors unhandled"
|
||||
# EXC0007
|
||||
- text: "Subprocess launch(ed with variable|ing should be audited)"
|
||||
linters:
|
||||
- gosec
|
||||
- text: "G204: Subprocess launch(ed with (variable|function call)|ing should be audited)"
|
||||
# EXC0008
|
||||
# TODO: evaluate these and fix where needed: G307: Deferring unsafe method "*os.File" on type "Close" (gosec)
|
||||
- text: "(G104|G307)"
|
||||
linters:
|
||||
- gosec
|
||||
- text: "(G301|G302): (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)"
|
||||
# EXC0009
|
||||
- text: "(Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)"
|
||||
linters:
|
||||
- gosec
|
||||
- text: "G304: Potential file inclusion via variable"
|
||||
# EXC0010
|
||||
- text: "Potential file inclusion via variable"
|
||||
linters:
|
||||
- gosec
|
||||
- text: "(G201|G202): SQL string (formatting|concatenation)"
|
||||
|
||||
# Looks like the match in "EXC0007" above doesn't catch this one
|
||||
# TODO: consider upstreaming this to golangci-lint's default exclusion rules
|
||||
- text: "G204: Subprocess launched with a potential tainted input or cmd arguments"
|
||||
linters:
|
||||
- gosec
|
||||
# Looks like the match in "EXC0009" above doesn't catch this one
|
||||
# TODO: consider upstreaming this to golangci-lint's default exclusion rules
|
||||
- text: "G306: Expect WriteFile permissions to be 0600 or less"
|
||||
linters:
|
||||
- gosec
|
||||
|
||||
# Exclude some linters from running on tests files.
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- errcheck
|
||||
- gosec
|
||||
|
||||
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
|
||||
max-issues-per-linter: 0
|
||||
|
||||
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
|
||||
max-same-issues: 0
|
||||
|
||||
25
Dockerfile
25
Dockerfile
@ -1,22 +1,13 @@
|
||||
# syntax=docker/dockerfile:1.3
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG BASE_VARIANT=alpine
|
||||
ARG GO_VERSION=1.16.8
|
||||
ARG GO_VERSION=1.18.9
|
||||
ARG ALPINE_VERSION=3.16
|
||||
ARG XX_VERSION=1.1.0
|
||||
|
||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${BASE_VARIANT} AS gostable
|
||||
FROM --platform=$BUILDPLATFORM golang:1.17rc1-${BASE_VARIANT} AS golatest
|
||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
||||
|
||||
FROM gostable AS go-linux
|
||||
FROM gostable AS go-darwin
|
||||
FROM gostable AS go-windows-amd64
|
||||
FROM gostable AS go-windows-386
|
||||
FROM gostable AS go-windows-arm
|
||||
FROM golatest AS go-windows-arm64
|
||||
FROM go-windows-${TARGETARCH} AS go-windows
|
||||
|
||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx@sha256:620d36a9d7f1e3b102a5c7e8eff12081ac363828b3a44390f24fa8da2d49383d AS xx
|
||||
|
||||
FROM go-${TARGETOS} AS build-base-alpine
|
||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build-base-alpine
|
||||
COPY --from=xx / /
|
||||
RUN apk add --no-cache clang lld llvm file git
|
||||
WORKDIR /go/src/github.com/docker/cli
|
||||
@ -26,7 +17,7 @@ ARG TARGETPLATFORM
|
||||
# gcc is installed for libgcc only
|
||||
RUN xx-apk add --no-cache musl-dev gcc
|
||||
|
||||
FROM go-${TARGETOS} AS build-base-buster
|
||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-buster AS build-base-buster
|
||||
COPY --from=xx / /
|
||||
RUN apt-get update && apt-get install --no-install-recommends -y clang lld file
|
||||
WORKDIR /go/src/github.com/docker/cli
|
||||
@ -54,7 +45,7 @@ RUN --mount=ro --mount=type=cache,target=/root/.cache \
|
||||
TARGET=/out ./scripts/build/binary && \
|
||||
xx-verify $([ "$GO_LINKMODE" = "static" ] && echo "--static") /out/docker
|
||||
|
||||
FROM build-base-${BASE_VARIANT} AS dev
|
||||
FROM build-base-${BASE_VARIANT} AS dev
|
||||
COPY . .
|
||||
|
||||
FROM scratch AS binary
|
||||
|
||||
@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli
|
||||
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
GOVERSION: 1.16.8
|
||||
GOVERSION: 1.18.9
|
||||
DEPVERSION: v0.4.1
|
||||
|
||||
install:
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package manager
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package manager
|
||||
|
||||
@ -19,13 +19,11 @@ func TestConfigContextFormatWrite(t *testing.T) {
|
||||
// Errors
|
||||
{
|
||||
formatter.Context{Format: "{{InvalidFunction}}"},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
formatter.Context{Format: "{{nil}}"},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table format
|
||||
{formatter.Context{Format: NewFormat("table", false)},
|
||||
|
||||
@ -36,7 +36,7 @@ func TestConfigInspectErrors(t *testing.T) {
|
||||
flags: map[string]string{
|
||||
"format": "{{invalid format}}",
|
||||
},
|
||||
expectedError: "Template parsing error",
|
||||
expectedError: "template parsing error",
|
||||
},
|
||||
{
|
||||
args: []string{"foo", "bar"},
|
||||
|
||||
@ -155,7 +155,7 @@ func (cid *cidFile) Close() error {
|
||||
return nil
|
||||
}
|
||||
if err := os.Remove(cid.path); err != nil {
|
||||
return errors.Errorf("failed to remove the CID file '%s': %s \n", cid.path, err)
|
||||
return errors.Wrapf(err, "failed to remove the CID file '%s'", cid.path)
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -166,7 +166,7 @@ func (cid *cidFile) Write(id string) error {
|
||||
return nil
|
||||
}
|
||||
if _, err := cid.file.Write([]byte(id)); err != nil {
|
||||
return errors.Errorf("Failed to write the container ID to the file: %s", err)
|
||||
return errors.Wrap(err, "failed to write the container ID to the file")
|
||||
}
|
||||
cid.written = true
|
||||
return nil
|
||||
@ -177,12 +177,12 @@ func newCIDFile(path string) (*cidFile, error) {
|
||||
return &cidFile{}, nil
|
||||
}
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return nil, errors.Errorf("Container ID file found, make sure the other container isn't running or delete %s", path)
|
||||
return nil, errors.Errorf("container ID file found, make sure the other container isn't running or delete %s", path)
|
||||
}
|
||||
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Failed to create the container ID file: %s", err)
|
||||
return nil, errors.Wrap(err, "failed to create the container ID file")
|
||||
}
|
||||
|
||||
return &cidFile{path: path, file: f}, nil
|
||||
|
||||
@ -39,7 +39,7 @@ func TestNewCIDFileWhenFileAlreadyExists(t *testing.T) {
|
||||
defer tempfile.Remove()
|
||||
|
||||
_, err := newCIDFile(tempfile.Path())
|
||||
assert.ErrorContains(t, err, "Container ID file found")
|
||||
assert.ErrorContains(t, err, "container ID file found")
|
||||
}
|
||||
|
||||
func TestCIDFileCloseWithNoWrite(t *testing.T) {
|
||||
|
||||
@ -181,14 +181,14 @@ func (c *statsContext) ID() string {
|
||||
|
||||
func (c *statsContext) CPUPerc() string {
|
||||
if c.s.IsInvalid {
|
||||
return fmt.Sprintf("--")
|
||||
return "--"
|
||||
}
|
||||
return fmt.Sprintf("%.2f%%", c.s.CPUPercentage)
|
||||
}
|
||||
|
||||
func (c *statsContext) MemUsage() string {
|
||||
if c.s.IsInvalid {
|
||||
return fmt.Sprintf("-- / --")
|
||||
return "-- / --"
|
||||
}
|
||||
if c.os == winOSType {
|
||||
return units.BytesSize(c.s.Memory)
|
||||
@ -198,28 +198,28 @@ func (c *statsContext) MemUsage() string {
|
||||
|
||||
func (c *statsContext) MemPerc() string {
|
||||
if c.s.IsInvalid || c.os == winOSType {
|
||||
return fmt.Sprintf("--")
|
||||
return "--"
|
||||
}
|
||||
return fmt.Sprintf("%.2f%%", c.s.MemoryPercentage)
|
||||
}
|
||||
|
||||
func (c *statsContext) NetIO() string {
|
||||
if c.s.IsInvalid {
|
||||
return fmt.Sprintf("--")
|
||||
return "--"
|
||||
}
|
||||
return fmt.Sprintf("%s / %s", units.HumanSizeWithPrecision(c.s.NetworkRx, 3), units.HumanSizeWithPrecision(c.s.NetworkTx, 3))
|
||||
}
|
||||
|
||||
func (c *statsContext) BlockIO() string {
|
||||
if c.s.IsInvalid {
|
||||
return fmt.Sprintf("--")
|
||||
return "--"
|
||||
}
|
||||
return fmt.Sprintf("%s / %s", units.HumanSizeWithPrecision(c.s.BlockRead, 3), units.HumanSizeWithPrecision(c.s.BlockWrite, 3))
|
||||
}
|
||||
|
||||
func (c *statsContext) PIDs() string {
|
||||
if c.s.IsInvalid || c.os == winOSType {
|
||||
return fmt.Sprintf("--")
|
||||
return "--"
|
||||
}
|
||||
return fmt.Sprintf("%d", c.s.PidsCurrent)
|
||||
}
|
||||
|
||||
@ -54,13 +54,11 @@ func TestContainerStatsContextWrite(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
formatter.Context{Format: "{{InvalidFunction}}"},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
formatter.Context{Format: "{{nil}}"},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
{
|
||||
formatter.Context{Format: "table {{.MemUsage}}"},
|
||||
|
||||
@ -14,13 +14,17 @@ import (
|
||||
)
|
||||
|
||||
func TestRemoveForce(t *testing.T) {
|
||||
var removed []string
|
||||
var (
|
||||
removed1 []string
|
||||
removed2 []string
|
||||
)
|
||||
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
containerRemoveFunc: func(ctx context.Context, container string, options types.ContainerRemoveOptions) error {
|
||||
removed = append(removed, container)
|
||||
removed1 = append(removed1, container)
|
||||
removed2 = append(removed2, container)
|
||||
if container == "nosuchcontainer" {
|
||||
return errdefs.NotFound(fmt.Errorf("Error: No such container: " + container))
|
||||
return errdefs.NotFound(fmt.Errorf("Error: no such container: " + container))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -31,16 +35,16 @@ func TestRemoveForce(t *testing.T) {
|
||||
|
||||
t.Run("without force", func(t *testing.T) {
|
||||
cmd.SetArgs([]string{"nosuchcontainer", "mycontainer"})
|
||||
removed = []string{}
|
||||
assert.ErrorContains(t, cmd.Execute(), "No such container")
|
||||
sort.Strings(removed)
|
||||
assert.DeepEqual(t, removed, []string{"mycontainer", "nosuchcontainer"})
|
||||
removed1 = []string{}
|
||||
assert.ErrorContains(t, cmd.Execute(), "no such container")
|
||||
sort.Strings(removed1)
|
||||
assert.DeepEqual(t, removed1, []string{"mycontainer", "nosuchcontainer"})
|
||||
})
|
||||
t.Run("with force", func(t *testing.T) {
|
||||
cmd.SetArgs([]string{"--force", "nosuchcontainer", "mycontainer"})
|
||||
removed = []string{}
|
||||
removed2 = []string{}
|
||||
assert.NilError(t, cmd.Execute())
|
||||
sort.Strings(removed)
|
||||
assert.DeepEqual(t, removed, []string{"mycontainer", "nosuchcontainer"})
|
||||
sort.Strings(removed2)
|
||||
assert.DeepEqual(t, removed2, []string{"mycontainer", "nosuchcontainer"})
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package container
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package container
|
||||
|
||||
@ -130,13 +130,11 @@ func TestContainerContextWrite(t *testing.T) {
|
||||
// Errors
|
||||
{
|
||||
Context{Format: "{{InvalidFunction}}"},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
Context{Format: "{{nil}}"},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table Format
|
||||
{
|
||||
|
||||
@ -61,8 +61,7 @@ CACHE ID CACHE TYPE SIZE CREATED LAST USED USAGE SHARED
|
||||
Format: "{{InvalidFunction}}",
|
||||
},
|
||||
},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
DiskUsageContext{
|
||||
@ -70,8 +69,7 @@ CACHE ID CACHE TYPE SIZE CREATED LAST USED USAGE SHARED
|
||||
Format: "{{nil}}",
|
||||
},
|
||||
},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table Format
|
||||
{
|
||||
|
||||
@ -64,7 +64,7 @@ func (c *Context) preFormat() {
|
||||
func (c *Context) parseFormat() (*template.Template, error) {
|
||||
tmpl, err := templates.Parse(c.finalFormat)
|
||||
if err != nil {
|
||||
return tmpl, errors.Errorf("Template parsing error: %v\n", err)
|
||||
return tmpl, errors.Wrap(err, "template parsing error")
|
||||
}
|
||||
return tmpl, err
|
||||
}
|
||||
@ -85,7 +85,7 @@ func (c *Context) postFormat(tmpl *template.Template, subContext SubContext) {
|
||||
|
||||
func (c *Context) contextFormat(tmpl *template.Template, subContext SubContext) error {
|
||||
if err := tmpl.Execute(c.buffer, subContext); err != nil {
|
||||
return errors.Errorf("Template parsing error: %v\n", err)
|
||||
return errors.Wrap(err, "template parsing error")
|
||||
}
|
||||
if c.Format.IsTable() && c.header != nil {
|
||||
c.header = subContext.FullHeader()
|
||||
|
||||
@ -119,8 +119,7 @@ func TestImageContextWrite(t *testing.T) {
|
||||
Format: "{{InvalidFunction}}",
|
||||
},
|
||||
},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
ImageContext{
|
||||
@ -128,8 +127,7 @@ func TestImageContextWrite(t *testing.T) {
|
||||
Format: "{{nil}}",
|
||||
},
|
||||
},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table Format
|
||||
{
|
||||
|
||||
@ -62,13 +62,11 @@ func TestVolumeContextWrite(t *testing.T) {
|
||||
// Errors
|
||||
{
|
||||
Context{Format: "{{InvalidFunction}}"},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
Context{Format: "{{nil}}"},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table format
|
||||
{
|
||||
|
||||
@ -297,7 +297,7 @@ func runBuild(dockerCli command.Cli, options buildOptions) error {
|
||||
}
|
||||
|
||||
if err := build.ValidateContextDirectory(contextDir, excludes); err != nil {
|
||||
return errors.Errorf("error checking context: '%s'.", err)
|
||||
return errors.Wrap(err, "error checking context")
|
||||
}
|
||||
|
||||
// And canonicalize dockerfile name to a platform-independent one
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package build
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
// +build windows
|
||||
|
||||
package build
|
||||
|
||||
import (
|
||||
|
||||
@ -44,7 +44,7 @@ func NewTemplateInspectorFromString(out io.Writer, tmplStr string) (Inspector, e
|
||||
|
||||
tmpl, err := templates.Parse(tmplStr)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Template parsing error: %s", err)
|
||||
return nil, errors.Errorf("template parsing error: %s", err)
|
||||
}
|
||||
return NewTemplateInspector(out, tmpl), nil
|
||||
}
|
||||
@ -94,7 +94,7 @@ func (i *TemplateInspector) Inspect(typedElement interface{}, rawElement []byte)
|
||||
buffer := new(bytes.Buffer)
|
||||
if err := i.tmpl.Execute(buffer, typedElement); err != nil {
|
||||
if rawElement == nil {
|
||||
return errors.Errorf("Template parsing error: %v", err)
|
||||
return errors.Errorf("template parsing error: %v", err)
|
||||
}
|
||||
return i.tryRawInspectFallback(rawElement)
|
||||
}
|
||||
@ -118,7 +118,7 @@ func (i *TemplateInspector) tryRawInspectFallback(rawElement []byte) error {
|
||||
|
||||
tmplMissingKey := i.tmpl.Option("missingkey=error")
|
||||
if rawErr := tmplMissingKey.Execute(buffer, raw); rawErr != nil {
|
||||
return errors.Errorf("Template parsing error: %v", rawErr)
|
||||
return errors.Errorf("template parsing error: %v", rawErr)
|
||||
}
|
||||
|
||||
i.buffer.Write(buffer.Bytes())
|
||||
|
||||
@ -62,7 +62,7 @@ func TestTemplateInspectorTemplateError(t *testing.T) {
|
||||
t.Fatal("Expected error got nil")
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(err.Error(), "Template parsing error") {
|
||||
if !strings.HasPrefix(err.Error(), "template parsing error") {
|
||||
t.Fatalf("Expected template error, got %v", err)
|
||||
}
|
||||
}
|
||||
@ -98,7 +98,7 @@ func TestTemplateInspectorRawFallbackError(t *testing.T) {
|
||||
t.Fatal("Expected error got nil")
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(err.Error(), "Template parsing error") {
|
||||
if !strings.HasPrefix(err.Error(), "template parsing error") {
|
||||
t.Fatalf("Expected template error, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,13 +79,11 @@ func TestNetworkContextWrite(t *testing.T) {
|
||||
// Errors
|
||||
{
|
||||
formatter.Context{Format: "{{InvalidFunction}}"},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
formatter.Context{Format: "{{nil}}"},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table format
|
||||
{
|
||||
|
||||
@ -62,15 +62,13 @@ func TestNodeContextWrite(t *testing.T) {
|
||||
|
||||
// Errors
|
||||
{
|
||||
context: formatter.Context{Format: "{{InvalidFunction}}"},
|
||||
expected: `Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
context: formatter.Context{Format: "{{InvalidFunction}}"},
|
||||
expected: `template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
clusterInfo: swarm.ClusterInfo{TLSInfo: swarm.TLSInfo{TrustRoot: "hi"}},
|
||||
},
|
||||
{
|
||||
context: formatter.Context{Format: "{{nil}}"},
|
||||
expected: `Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
context: formatter.Context{Format: "{{nil}}"},
|
||||
expected: `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
clusterInfo: swarm.ClusterInfo{TLSInfo: swarm.TLSInfo{TrustRoot: "hi"}},
|
||||
},
|
||||
// Table format
|
||||
|
||||
@ -59,13 +59,11 @@ func TestPluginContextWrite(t *testing.T) {
|
||||
// Errors
|
||||
{
|
||||
formatter.Context{Format: "{{InvalidFunction}}"},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
formatter.Context{Format: "{{nil}}"},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table format
|
||||
{
|
||||
|
||||
@ -61,7 +61,7 @@ func TestInspectErrors(t *testing.T) {
|
||||
flags: map[string]string{
|
||||
"format": "{{invalid format}}",
|
||||
},
|
||||
expectedError: "Template parsing error",
|
||||
expectedError: "template parsing error",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ func TestListErrors(t *testing.T) {
|
||||
flags: map[string]string{
|
||||
"format": "{{invalid format}}",
|
||||
},
|
||||
expectedError: "Template parsing error",
|
||||
expectedError: "template parsing error",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -112,13 +112,11 @@ func TestSearchContextWrite(t *testing.T) {
|
||||
// Errors
|
||||
{
|
||||
formatter.Context{Format: "{{InvalidFunction}}"},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
formatter.Context{Format: "{{nil}}"},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table format
|
||||
{
|
||||
|
||||
@ -19,13 +19,11 @@ func TestSecretContextFormatWrite(t *testing.T) {
|
||||
// Errors
|
||||
{
|
||||
formatter.Context{Format: "{{InvalidFunction}}"},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
formatter.Context{Format: "{{nil}}"},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table format
|
||||
{formatter.Context{Format: NewFormat("table", false)},
|
||||
|
||||
@ -36,7 +36,7 @@ func TestSecretInspectErrors(t *testing.T) {
|
||||
flags: map[string]string{
|
||||
"format": "{{invalid format}}",
|
||||
},
|
||||
expectedError: "Template parsing error",
|
||||
expectedError: "template parsing error",
|
||||
},
|
||||
{
|
||||
args: []string{"foo", "bar"},
|
||||
|
||||
@ -29,13 +29,11 @@ func TestServiceContextWrite(t *testing.T) {
|
||||
// Errors
|
||||
{
|
||||
formatter.Context{Format: "{{InvalidFunction}}"},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
formatter.Context{Format: "{{nil}}"},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table format
|
||||
{
|
||||
|
||||
@ -914,7 +914,7 @@ func addServiceFlags(flags *pflag.FlagSet, opts *serviceOptions, defaultFlagValu
|
||||
}
|
||||
|
||||
const (
|
||||
flagCredentialSpec = "credential-spec"
|
||||
flagCredentialSpec = "credential-spec" //nolint:gosec // ignore G101: Potential hardcoded credentials
|
||||
flagPlacementPref = "placement-pref"
|
||||
flagPlacementPrefAdd = "placement-pref-add"
|
||||
flagPlacementPrefRemove = "placement-pref-rm"
|
||||
|
||||
@ -16,13 +16,11 @@ func TestStackContextWrite(t *testing.T) {
|
||||
// Errors
|
||||
{
|
||||
formatter.Context{Format: "{{InvalidFunction}}"},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
formatter.Context{Format: "{{nil}}"},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table format
|
||||
{
|
||||
|
||||
@ -33,7 +33,7 @@ func TestListErrors(t *testing.T) {
|
||||
flags: map[string]string{
|
||||
"format": "{{invalid format}}",
|
||||
},
|
||||
expectedError: "Template parsing error",
|
||||
expectedError: "template parsing error",
|
||||
},
|
||||
{
|
||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
||||
|
||||
@ -28,6 +28,7 @@ func LoadComposefile(dockerCli command.Cli, opts options.Deploy) (*composetypes.
|
||||
config, err := loader.Load(configDetails)
|
||||
if err != nil {
|
||||
if fpe, ok := err.(*loader.ForbiddenPropertiesError); ok {
|
||||
//nolint:revive // ignore capitalization error; this error is intentionally formatted multi-line
|
||||
return nil, errors.Errorf("Compose file contains unsupported options:\n\n%s\n",
|
||||
propertyWarnings(fpe.Properties))
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ func TestStackServicesErrors(t *testing.T) {
|
||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{*Service()}, nil
|
||||
},
|
||||
expectedError: "Template parsing error",
|
||||
expectedError: "template parsing error",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"github.com/docker/cli/templates"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/docker/go-units"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@ -211,9 +212,6 @@ func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) []error {
|
||||
for _, o := range so.Options {
|
||||
switch o.Key {
|
||||
case "profile":
|
||||
if o.Value != "default" {
|
||||
fmt.Fprintln(dockerCli.Err(), " WARNING: You're not using the default seccomp profile")
|
||||
}
|
||||
fmt.Fprintln(dockerCli.Out(), " Profile:", o.Value)
|
||||
}
|
||||
}
|
||||
@ -378,6 +376,9 @@ func printSwarmInfo(dockerCli command.Cli, info types.Info) {
|
||||
}
|
||||
|
||||
func printServerWarnings(dockerCli command.Cli, info types.Info) {
|
||||
if versions.LessThan(dockerCli.Client().ClientVersion(), "1.42") {
|
||||
printSecurityOptionsWarnings(dockerCli, info)
|
||||
}
|
||||
if len(info.Warnings) > 0 {
|
||||
fmt.Fprintln(dockerCli.Err(), strings.Join(info.Warnings, "\n"))
|
||||
return
|
||||
@ -387,6 +388,29 @@ func printServerWarnings(dockerCli command.Cli, info types.Info) {
|
||||
printServerWarningsLegacy(dockerCli, info)
|
||||
}
|
||||
|
||||
// printSecurityOptionsWarnings prints warnings based on the security options
|
||||
// returned by the daemon.
|
||||
// DEPRECATED: warnings are now generated by the daemon, and returned in
|
||||
// info.Warnings. This function is used to provide backward compatibility with
|
||||
// daemons that do not provide these warnings. No new warnings should be added
|
||||
// here.
|
||||
func printSecurityOptionsWarnings(dockerCli command.Cli, info types.Info) {
|
||||
if info.OSType == "windows" {
|
||||
return
|
||||
}
|
||||
kvs, _ := types.DecodeSecurityOptions(info.SecurityOptions)
|
||||
for _, so := range kvs {
|
||||
if so.Name != "seccomp" {
|
||||
continue
|
||||
}
|
||||
for _, o := range so.Options {
|
||||
if o.Key == "profile" && o.Value != "default" && o.Value != "builtin" {
|
||||
_, _ = fmt.Fprintln(dockerCli.Err(), "WARNING: You're not using the default seccomp profile")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// printServerWarningsLegacy generates warnings based on information returned by the daemon.
|
||||
// DEPRECATED: warnings are now generated by the daemon, and returned in
|
||||
// info.Warnings. This function is used to provide backward compatibility with
|
||||
@ -482,7 +506,7 @@ func formatInfo(dockerCli command.Cli, info info, format string) error {
|
||||
tmpl, err := templates.Parse(format)
|
||||
if err != nil {
|
||||
return cli.StatusError{StatusCode: 64,
|
||||
Status: "Template parsing error: " + err.Error()}
|
||||
Status: "template parsing error: " + err.Error()}
|
||||
}
|
||||
err = tmpl.Execute(dockerCli.Out(), info)
|
||||
dockerCli.Out().Write([]byte{'\n'})
|
||||
|
||||
@ -394,7 +394,7 @@ func TestFormatInfo(t *testing.T) {
|
||||
{
|
||||
doc: "syntax",
|
||||
template: "{{}",
|
||||
expectedError: `Status: Template parsing error: template: :1: unexpected "}" in command, Code: 64`,
|
||||
expectedError: `Status: template parsing error: template: :1: unexpected "}" in command, Code: 64`,
|
||||
},
|
||||
{
|
||||
doc: "syntax",
|
||||
|
||||
@ -235,7 +235,7 @@ func newVersionTemplate(templateFormat string) (*template.Template, error) {
|
||||
tmpl := templates.New("version").Funcs(template.FuncMap{"getDetailsOrder": getDetailsOrder})
|
||||
tmpl, err := tmpl.Parse(templateFormat)
|
||||
|
||||
return tmpl, errors.Wrap(err, "Template parsing error")
|
||||
return tmpl, errors.Wrap(err, "template parsing error")
|
||||
}
|
||||
|
||||
func getDetailsOrder(v types.ComponentVersion) []string {
|
||||
|
||||
@ -20,13 +20,11 @@ func TestTaskContextWrite(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
formatter.Context{Format: "{{InvalidFunction}}"},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
formatter.Context{Format: "{{nil}}"},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
{
|
||||
formatter.Context{Format: NewTaskFormat("table", true)},
|
||||
|
||||
@ -95,15 +95,13 @@ func TestTrustTagContextWrite(t *testing.T) {
|
||||
formatter.Context{
|
||||
Format: "{{InvalidFunction}}",
|
||||
},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
formatter.Context{
|
||||
Format: "{{nil}}",
|
||||
},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table Format
|
||||
{
|
||||
@ -191,15 +189,13 @@ func TestSignerInfoContextWrite(t *testing.T) {
|
||||
formatter.Context{
|
||||
Format: "{{InvalidFunction}}",
|
||||
},
|
||||
`Template parsing error: template: :1: function "InvalidFunction" not defined
|
||||
`,
|
||||
`template parsing error: template: :1: function "InvalidFunction" not defined`,
|
||||
},
|
||||
{
|
||||
formatter.Context{
|
||||
Format: "{{nil}}",
|
||||
},
|
||||
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command
|
||||
`,
|
||||
`template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
|
||||
},
|
||||
// Table Format
|
||||
{
|
||||
|
||||
@ -32,7 +32,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) == 1 {
|
||||
if options.name != "" {
|
||||
return errors.Errorf("Conflicting options: either specify --name or provide positional arg, not both\n")
|
||||
return errors.Errorf("conflicting options: either specify --name or provide positional arg, not both")
|
||||
}
|
||||
options.name = args[0]
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ func TestVolumeCreateErrors(t *testing.T) {
|
||||
flags: map[string]string{
|
||||
"name": "volumeName",
|
||||
},
|
||||
expectedError: "Conflicting options: either specify --name or provide positional arg, not both",
|
||||
expectedError: "conflicting options: either specify --name or provide positional arg, not both",
|
||||
},
|
||||
{
|
||||
args: []string{"too", "many"},
|
||||
|
||||
@ -35,7 +35,7 @@ func TestVolumeInspectErrors(t *testing.T) {
|
||||
flags: map[string]string{
|
||||
"format": "{{invalid format}}",
|
||||
},
|
||||
expectedError: "Template parsing error",
|
||||
expectedError: "template parsing error",
|
||||
},
|
||||
{
|
||||
args: []string{"foo", "bar"},
|
||||
|
||||
@ -99,7 +99,7 @@ func newPathError(path Path, err error) error {
|
||||
return nil
|
||||
case *template.InvalidTemplateError:
|
||||
return errors.Errorf(
|
||||
"invalid interpolation format for %s: %#v. You may need to escape any $ with another $.",
|
||||
"invalid interpolation format for %s: %#v; you may need to escape any $ with another $",
|
||||
path, err.Template)
|
||||
default:
|
||||
return errors.Wrapf(err, "error while interpolating %s", path)
|
||||
|
||||
@ -58,7 +58,7 @@ func TestInvalidInterpolation(t *testing.T) {
|
||||
},
|
||||
}
|
||||
_, err := Interpolate(services, Options{LookupValue: defaultMapping})
|
||||
assert.Error(t, err, `invalid interpolation format for servicea.image: "${". You may need to escape any $ with another $.`)
|
||||
assert.Error(t, err, `invalid interpolation format for servicea.image: "${"; you may need to escape any $ with another $`)
|
||||
}
|
||||
|
||||
func TestInterpolateWithDefaults(t *testing.T) {
|
||||
|
||||
@ -104,14 +104,18 @@ func LoadFromReader(configData io.Reader) (*configfile.ConfigFile, error) {
|
||||
return &configFile, err
|
||||
}
|
||||
|
||||
// TODO remove this temporary hack, which is used to warn about the deprecated ~/.dockercfg file
|
||||
var printLegacyFileWarning bool
|
||||
|
||||
// Load reads the configuration files in the given directory, and sets up
|
||||
// the auth config information and returns values.
|
||||
// FIXME: use the internal golang config parser
|
||||
func Load(configDir string) (*configfile.ConfigFile, error) {
|
||||
printLegacyFileWarning = false
|
||||
cfg, _, err := load(configDir)
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
// TODO remove this temporary hack, which is used to warn about the deprecated ~/.dockercfg file
|
||||
// so we can remove the bool return value and collapse this back into `Load`
|
||||
func load(configDir string) (*configfile.ConfigFile, bool, error) {
|
||||
printLegacyFileWarning := false
|
||||
|
||||
if configDir == "" {
|
||||
configDir = Dir()
|
||||
@ -127,11 +131,11 @@ func Load(configDir string) (*configfile.ConfigFile, error) {
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, filename)
|
||||
}
|
||||
return configFile, err
|
||||
return configFile, printLegacyFileWarning, err
|
||||
} else if !os.IsNotExist(err) {
|
||||
// if file is there but we can't stat it for any reason other
|
||||
// than it doesn't exist then stop
|
||||
return configFile, errors.Wrap(err, filename)
|
||||
return configFile, printLegacyFileWarning, errors.Wrap(err, filename)
|
||||
}
|
||||
|
||||
// Can't find latest config file so check for the old one
|
||||
@ -140,16 +144,16 @@ func Load(configDir string) (*configfile.ConfigFile, error) {
|
||||
printLegacyFileWarning = true
|
||||
defer file.Close()
|
||||
if err := configFile.LegacyLoadFromReader(file); err != nil {
|
||||
return configFile, errors.Wrap(err, filename)
|
||||
return configFile, printLegacyFileWarning, errors.Wrap(err, filename)
|
||||
}
|
||||
}
|
||||
return configFile, nil
|
||||
return configFile, printLegacyFileWarning, nil
|
||||
}
|
||||
|
||||
// LoadDefaultConfigFile attempts to load the default config file and returns
|
||||
// an initialized ConfigFile struct if none is found.
|
||||
func LoadDefaultConfigFile(stderr io.Writer) *configfile.ConfigFile {
|
||||
configFile, err := Load(Dir())
|
||||
configFile, printLegacyFileWarning, err := load(Dir())
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "WARNING: Error loading config file: %v\n", err)
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ func (configFile *ConfigFile) LegacyLoadFromReader(configData io.Reader) error {
|
||||
// LoadFromReader reads the configuration data given and sets up the auth config
|
||||
// information with given directory and populates the receiver object
|
||||
func (configFile *ConfigFile) LoadFromReader(configData io.Reader) error {
|
||||
if err := json.NewDecoder(configData).Decode(&configFile); err != nil && !errors.Is(err, io.EOF) {
|
||||
if err := json.NewDecoder(configData).Decode(configFile); err != nil && !errors.Is(err, io.EOF) {
|
||||
return err
|
||||
}
|
||||
var err error
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package configfile
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
//go:build !windows && !darwin && !linux
|
||||
// +build !windows,!darwin,!linux
|
||||
|
||||
package credentials
|
||||
|
||||
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
remoteCredentialsPrefix = "docker-credential-"
|
||||
remoteCredentialsPrefix = "docker-credential-" //nolint:gosec // ignore G101: Potential hardcoded credentials
|
||||
tokenUsername = "<token>"
|
||||
)
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package commandconn
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
//go:build !linux
|
||||
// +build !linux
|
||||
|
||||
package commandconn
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package commandconn
|
||||
|
||||
@ -1954,6 +1954,7 @@ _docker_container_run_and_create() {
|
||||
--oom-score-adj
|
||||
--pid
|
||||
--pids-limit
|
||||
--platform
|
||||
--publish -p
|
||||
--pull
|
||||
--restart
|
||||
@ -1981,9 +1982,6 @@ _docker_container_run_and_create() {
|
||||
--io-maxiops
|
||||
--isolation
|
||||
"
|
||||
__docker_server_is_experimental && options_with_args+="
|
||||
--platform
|
||||
"
|
||||
|
||||
local boolean_options="
|
||||
--disable-content-trust=false
|
||||
@ -2831,6 +2829,7 @@ _docker_image_build() {
|
||||
--memory -m
|
||||
--memory-swap
|
||||
--network
|
||||
--platform
|
||||
--shm-size
|
||||
--tag -t
|
||||
--target
|
||||
@ -2851,9 +2850,6 @@ _docker_image_build() {
|
||||
"
|
||||
|
||||
if __docker_server_is_experimental ; then
|
||||
options_with_args+="
|
||||
--platform
|
||||
"
|
||||
boolean_options+="
|
||||
--squash
|
||||
"
|
||||
@ -2862,7 +2858,6 @@ _docker_image_build() {
|
||||
if [ "$DOCKER_BUILDKIT" = "1" ] ; then
|
||||
options_with_args+="
|
||||
--output -o
|
||||
--platform
|
||||
--progress
|
||||
--secret
|
||||
--ssh
|
||||
@ -2993,8 +2988,7 @@ _docker_image_import() {
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
local options="--change -c --help --message -m"
|
||||
__docker_server_is_experimental && options+=" --platform"
|
||||
local options="--change -c --help --message -m --platform"
|
||||
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
@ -3102,9 +3096,7 @@ _docker_image_pull() {
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
local options="--all-tags -a --disable-content-trust=false --help --quiet -q"
|
||||
__docker_server_is_experimental && options+=" --platform"
|
||||
|
||||
local options="--all-tags -a --disable-content-trust=false --help --platform --quiet -q"
|
||||
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
@ -5485,6 +5477,23 @@ _docker_wait() {
|
||||
_docker_container_wait
|
||||
}
|
||||
|
||||
COMPOSE_PLUGIN_PATH=$(docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}')
|
||||
|
||||
_docker_compose() {
|
||||
local completionCommand="__completeNoDesc"
|
||||
local resultArray=($COMPOSE_PLUGIN_PATH $completionCommand compose)
|
||||
for value in "${words[@]:2}"; do
|
||||
if [ -z "$value" ]; then
|
||||
resultArray+=( "''" )
|
||||
else
|
||||
resultArray+=( "$value" )
|
||||
fi
|
||||
done
|
||||
local result=$(eval "${resultArray[*]}" 2> /dev/null | grep -v '^:[0-9]*$')
|
||||
|
||||
COMPREPLY=( $(compgen -W "${result}" -- "$current") )
|
||||
}
|
||||
|
||||
_docker() {
|
||||
local previous_extglob_setting=$(shopt -p extglob)
|
||||
shopt -s extglob
|
||||
@ -5554,11 +5563,17 @@ _docker() {
|
||||
wait
|
||||
)
|
||||
|
||||
local known_plugin_commands=()
|
||||
|
||||
if [ -f "$COMPOSE_PLUGIN_PATH" ] ; then
|
||||
known_plugin_commands+=("compose")
|
||||
fi
|
||||
|
||||
local experimental_server_commands=(
|
||||
checkpoint
|
||||
)
|
||||
|
||||
local commands=(${management_commands[*]} ${top_level_commands[*]})
|
||||
local commands=(${management_commands[*]} ${top_level_commands[*]} ${known_plugin_commands[*]})
|
||||
[ -z "$DOCKER_HIDE_LEGACY_COMMANDS" ] && commands+=(${legacy_commands[*]})
|
||||
|
||||
# These options are valid as global options for all client commands
|
||||
|
||||
@ -2652,7 +2652,7 @@ __docker_commands() {
|
||||
then
|
||||
local -a lines
|
||||
lines=(${(f)"$(_call_program commands docker 2>&1)"})
|
||||
_docker_subcommands=(${${${(M)${lines[$((${lines[(i)*Commands:]} + 1)),-1]}:# *}## #}/ ##/:})
|
||||
_docker_subcommands=(${${${(M)${lines[$((${lines[(i)*Commands:]} + 1)),-1]}:# *}## #}/\*# ##/:})
|
||||
_docker_subcommands=($_docker_subcommands 'daemon:Enable daemon mode' 'help:Show help for a command')
|
||||
(( $#_docker_subcommands > 2 )) && _store_cache docker_subcommands _docker_subcommands
|
||||
fi
|
||||
@ -3094,6 +3094,7 @@ _docker() {
|
||||
_arguments $(__docker_arguments) -C \
|
||||
"(: -)"{-h,--help}"[Print usage]" \
|
||||
"($help)--config[Location of client config files]:path:_directories" \
|
||||
"($help -c --context)"{-c=,--context=}"[Execute the command in a docker context]:context:__docker_complete_contexts" \
|
||||
"($help -D --debug)"{-D,--debug}"[Enable debug mode]" \
|
||||
"($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \
|
||||
"($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \
|
||||
@ -3109,7 +3110,8 @@ _docker() {
|
||||
|
||||
local host=${opt_args[-H]}${opt_args[--host]}
|
||||
local config=${opt_args[--config]}
|
||||
local docker_options="${host:+--host $host} ${config:+--config $config}"
|
||||
local context=${opt_args[-c]}${opt_args[--context]}
|
||||
local docker_options="${host:+--host $host} ${config:+--config $config} ${context:+--context $context} "
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
variable "GO_VERSION" {
|
||||
default = "1.18.9"
|
||||
}
|
||||
variable "VERSION" {
|
||||
default = ""
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
ARG GO_VERSION=1.16.8
|
||||
ARG GO_VERSION=1.18.9
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
# syntax=docker/dockerfile:1.3
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.16.8
|
||||
ARG GO_VERSION=1.18.9
|
||||
ARG ALPINE_VERSION=3.16
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine AS golang
|
||||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS golang
|
||||
ENV CGO_ENABLED=0
|
||||
|
||||
FROM golang AS esc
|
||||
@ -13,7 +14,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
GO111MODULE=on go install github.com/mjibson/esc@${ESC_VERSION}
|
||||
|
||||
FROM golang AS gotestsum
|
||||
ARG GOTESTSUM_VERSION=v0.4.0
|
||||
ARG GOTESTSUM_VERSION=v1.8.2
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=tmpfs,target=/go/src/ \
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
ARG GO_VERSION=1.16.8
|
||||
ARG GO_VERSION=1.18.9
|
||||
|
||||
# Use Debian based image as docker-compose requires glibc.
|
||||
FROM golang:${GO_VERSION}-buster
|
||||
@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y \
|
||||
openssh-client \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ARG COMPOSE_VERSION=1.25.1
|
||||
ARG COMPOSE_VERSION=1.29.2
|
||||
RUN curl -fsSL https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose \
|
||||
&& chmod +x /usr/local/bin/docker-compose
|
||||
|
||||
@ -18,7 +18,7 @@ ARG NOTARY_VERSION=v0.6.1
|
||||
RUN curl -fsSL https://github.com/theupdateframework/notary/releases/download/${NOTARY_VERSION}/notary-Linux-amd64 -o /usr/local/bin/notary \
|
||||
&& chmod +x /usr/local/bin/notary
|
||||
|
||||
ARG GOTESTSUM_VERSION=0.4.0
|
||||
ARG GOTESTSUM_VERSION=1.8.2
|
||||
RUN curl -fsSL https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz -o gotestsum.tar.gz \
|
||||
&& tar -xf gotestsum.tar.gz gotestsum \
|
||||
&& mv gotestsum /usr/local/bin/gotestsum \
|
||||
@ -39,7 +39,6 @@ ARG GITCOMMIT
|
||||
ENV VERSION=${VERSION}
|
||||
ENV GITCOMMIT=${GITCOMMIT}
|
||||
ENV DOCKER_BUILDKIT=1
|
||||
ENV COMPOSE_DOCKER_CLI_BUILD=1
|
||||
RUN ./scripts/build/binary
|
||||
RUN ./scripts/build/plugins e2e/cli-plugins/plugins/*
|
||||
|
||||
|
||||
@ -1,18 +1,19 @@
|
||||
# syntax=docker/dockerfile:1.3
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.16.8
|
||||
ARG GOLANGCI_LINTER_SHA="v1.21.0"
|
||||
ARG GO_VERSION=1.18.9
|
||||
ARG ALPINE_VERSION=3.16
|
||||
ARG GOLANGCI_LINT_VERSION=v1.45.2
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine AS build
|
||||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build
|
||||
ENV CGO_ENABLED=0
|
||||
RUN apk add --no-cache git
|
||||
ARG GOLANGCI_LINTER_SHA
|
||||
ARG GOLANGCI_LINT_VERSION
|
||||
ARG GO111MODULE=on
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg/mod \
|
||||
go get github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINTER_SHA}
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine AS lint
|
||||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS lint
|
||||
ENV GO111MODULE=off
|
||||
ENV CGO_ENABLED=0
|
||||
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
|
||||
|
||||
@ -48,56 +48,58 @@ The table below provides an overview of the current status of deprecated feature
|
||||
alternatives. In such cases, a warning may be printed, and users should not rely
|
||||
on this feature.
|
||||
|
||||
Status | Feature | Deprecated | Remove
|
||||
-----------|------------------------------------------------------------------------------------------------------------------------------------|------------|------------
|
||||
Deprecated | [Support for encrypted TLS private keys](#support-for-encrypted-tls-private-keys) | v20.10 | -
|
||||
Deprecated | [Kubernetes stack and context support](#kubernetes-stack-and-context-support) | v20.10 | -
|
||||
Deprecated | [Pulling images from non-compliant image registries](#pulling-images-from-non-compliant-image-registries) | v20.10 | -
|
||||
Deprecated | [Linux containers on Windows (LCOW)](#linux-containers-on-windows-lcow-experimental) | v20.10 | -
|
||||
Deprecated | [BLKIO weight options with cgroups v1](#blkio-weight-options–with-cgroups-v1) | v20.10 | -
|
||||
Deprecated | [Kernel memory limit](#kernel-memory-limit) | v20.10 | -
|
||||
Deprecated | [Classic Swarm and overlay networks using external key/value stores](#classic-swarm-and-overlay-networks-using-cluster-store) | v20.10 | -
|
||||
Deprecated | [Support for the legacy `~/.dockercfg` configuration file for authentication](#support-for-legacy-dockercfg-configuration-files) | v20.10 | -
|
||||
Deprecated | [CLI plugins support](#cli-plugins-support) | v20.10 | -
|
||||
Deprecated | [Dockerfile legacy `ENV name value` syntax](#dockerfile-legacy-env-name-value-syntax) | v20.10 | -
|
||||
Removed | [`docker build --stream` flag (experimental)](#docker-build---stream-flag-experimental) | v20.10 | v20.10
|
||||
Deprecated | [Configuration options for experimental CLI features](#configuration-options-for-experimental-cli-features) | v19.03 | v20.10
|
||||
Deprecated | [Pushing and pulling with image manifest v2 schema 1](#pushing-and-pulling-with-image-manifest-v2-schema-1) | v19.03 | v20.10
|
||||
Removed | [`docker engine` subcommands](#docker-engine-subcommands) | v19.03 | v20.10
|
||||
Removed | [Top-level `docker deploy` subcommand (experimental)](#top-level-docker-deploy-subcommand-experimental) | v19.03 | v20.10
|
||||
Removed | [`docker stack deploy` using "dab" files (experimental)](#docker-stack-deploy-using-dab-files-experimental) | v19.03 | v20.10
|
||||
Deprecated | [AuFS storage driver](#aufs-storage-driver) | v19.03 | -
|
||||
Deprecated | [Legacy "overlay" storage driver](#legacy-overlay-storage-driver) | v18.09 | -
|
||||
Deprecated | [Device mapper storage driver](#device-mapper-storage-driver) | v18.09 | -
|
||||
Removed | [Use of reserved namespaces in engine labels](#use-of-reserved-namespaces-in-engine-labels) | v18.06 | v20.10
|
||||
Removed | [`--disable-legacy-registry` override daemon option](#--disable-legacy-registry-override-daemon-option) | v17.12 | v19.03
|
||||
Removed | [Interacting with V1 registries](#interacting-with-v1-registries) | v17.06 | v17.12
|
||||
Removed | [Asynchronous `service create` and `service update` as default](#asynchronous-service-create-and-service-update-as-default) | v17.05 | v17.10
|
||||
Removed | [`-g` and `--graph` flags on `dockerd`](#-g-and---graph-flags-on-dockerd) | v17.05 | -
|
||||
Deprecated | [Top-level network properties in NetworkSettings](#top-level-network-properties-in-networksettings) | v1.13 | v17.12
|
||||
Removed | [`filter` param for `/images/json` endpoint](#filter-param-for-imagesjson-endpoint) | v1.13 | v20.10
|
||||
Removed | [`repository:shortid` image references](#repositoryshortid-image-references) | v1.13 | v17.12
|
||||
Removed | [`docker daemon` subcommand](#docker-daemon-subcommand) | v1.13 | v17.12
|
||||
Removed | [Duplicate keys with conflicting values in engine labels](#duplicate-keys-with-conflicting-values-in-engine-labels) | v1.13 | v17.12
|
||||
Deprecated | [`MAINTAINER` in Dockerfile](#maintainer-in-dockerfile) | v1.13 | -
|
||||
Deprecated | [API calls without a version](#api-calls-without-a-version) | v1.13 | v17.12
|
||||
Removed | [Backing filesystem without `d_type` support for overlay/overlay2](#backing-filesystem-without-d_type-support-for-overlayoverlay2) | v1.13 | v17.12
|
||||
Removed | [`--automated` and `--stars` flags on `docker search`](#--automated-and---stars-flags-on-docker-search) | v1.12 | v20.10
|
||||
Deprecated | [`-h` shorthand for `--help`](#-h-shorthand-for---help) | v1.12 | v17.09
|
||||
Removed | [`-e` and `--email` flags on `docker login`](#-e-and---email-flags-on-docker-login) | v1.11 | v17.06
|
||||
Deprecated | [Separator (`:`) of `--security-opt` flag on `docker run`](#separator--of---security-opt-flag-on-docker-run) | v1.11 | v17.06
|
||||
Deprecated | [Ambiguous event fields in API](#ambiguous-event-fields-in-api) | v1.10 | -
|
||||
Removed | [`-f` flag on `docker tag`](#-f-flag-on-docker-tag) | v1.10 | v1.12
|
||||
Removed | [HostConfig at API container start](#hostconfig-at-api-container-start) | v1.10 | v1.12
|
||||
Removed | [`--before` and `--since` flags on `docker ps`](#--before-and---since-flags-on-docker-ps) | v1.10 | v1.12
|
||||
Removed | [Driver-specific log tags](#driver-specific-log-tags) | v1.9 | v1.12
|
||||
Removed | [Docker Content Trust `ENV` passphrase variables name change](#docker-content-trust-env-passphrase-variables-name-change) | v1.9 | v1.12
|
||||
Removed | [`/containers/(id or name)/copy` endpoint](#containersid-or-namecopy-endpoint) | v1.8 | v1.12
|
||||
Removed | [LXC built-in exec driver](#lxc-built-in-exec-driver) | v1.8 | v1.10
|
||||
Removed | [Old Command Line Options](#old-command-line-options) | v1.8 | v1.10
|
||||
Removed | [`--api-enable-cors` flag on `dockerd`](#--api-enable-cors-flag-on-dockerd) | v1.6 | v17.09
|
||||
Removed | [`--run` flag on `docker commit`](#--run-flag-on-docker-commit) | v0.10 | v1.13
|
||||
Removed | [Three arguments form in `docker import`](#three-arguments-form-in-docker-import) | v0.6.7 | v1.12
|
||||
| Status | Feature | Deprecated | Remove |
|
||||
|------------|------------------------------------------------------------------------------------------------------------------------------------|------------|--------|
|
||||
| Deprecated | [Support for encrypted TLS private keys](#support-for-encrypted-tls-private-keys) | v20.10 | - |
|
||||
| Deprecated | [Kubernetes stack and context support](#kubernetes-stack-and-context-support) | v20.10 | - |
|
||||
| Deprecated | [Pulling images from non-compliant image registries](#pulling-images-from-non-compliant-image-registries) | v20.10 | - |
|
||||
| Deprecated | [Linux containers on Windows (LCOW)](#linux-containers-on-windows-lcow-experimental) | v20.10 | - |
|
||||
| Deprecated | [BLKIO weight options with cgroups v1](#blkio-weight-options-with-cgroups-v1) | v20.10 | - |
|
||||
| Deprecated | [Kernel memory limit](#kernel-memory-limit) | v20.10 | - |
|
||||
| Deprecated | [Classic Swarm and overlay networks using external key/value stores](#classic-swarm-and-overlay-networks-using-cluster-store) | v20.10 | - |
|
||||
| Deprecated | [Support for the legacy `~/.dockercfg` configuration file for authentication](#support-for-legacy-dockercfg-configuration-files) | v20.10 | - |
|
||||
| Deprecated | [CLI plugins support](#cli-plugins-support) | v20.10 | - |
|
||||
| Deprecated | [Dockerfile legacy `ENV name value` syntax](#dockerfile-legacy-env-name-value-syntax) | v20.10 | - |
|
||||
| Removed | [`docker build --stream` flag (experimental)](#docker-build---stream-flag-experimental) | v20.10 | v20.10 |
|
||||
| Deprecated | [`fluentd-async-connect` log opt](#fluentd-async-connect-log-opt) | v20.10 | - |
|
||||
| Deprecated | [Configuration options for experimental CLI features](#configuration-options-for-experimental-cli-features) | v19.03 | v20.10 |
|
||||
| Deprecated | [Pushing and pulling with image manifest v2 schema 1](#pushing-and-pulling-with-image-manifest-v2-schema-1) | v19.03 | v20.10 |
|
||||
| Removed | [`docker engine` subcommands](#docker-engine-subcommands) | v19.03 | v20.10 |
|
||||
| Removed | [Top-level `docker deploy` subcommand (experimental)](#top-level-docker-deploy-subcommand-experimental) | v19.03 | v20.10 |
|
||||
| Removed | [`docker stack deploy` using "dab" files (experimental)](#docker-stack-deploy-using-dab-files-experimental) | v19.03 | v20.10 |
|
||||
| Disabled | [Support for the `overlay2.override_kernel_check` storage option](#support-for-the-overlay2override_kernel_check-storage-option) | v19.03 | - |
|
||||
| Deprecated | [AuFS storage driver](#aufs-storage-driver) | v19.03 | - |
|
||||
| Deprecated | [Legacy "overlay" storage driver](#legacy-overlay-storage-driver) | v18.09 | - |
|
||||
| Deprecated | [Device mapper storage driver](#device-mapper-storage-driver) | v18.09 | - |
|
||||
| Removed | [Use of reserved namespaces in engine labels](#use-of-reserved-namespaces-in-engine-labels) | v18.06 | v20.10 |
|
||||
| Removed | [`--disable-legacy-registry` override daemon option](#--disable-legacy-registry-override-daemon-option) | v17.12 | v19.03 |
|
||||
| Removed | [Interacting with V1 registries](#interacting-with-v1-registries) | v17.06 | v17.12 |
|
||||
| Removed | [Asynchronous `service create` and `service update` as default](#asynchronous-service-create-and-service-update-as-default) | v17.05 | v17.10 |
|
||||
| Removed | [`-g` and `--graph` flags on `dockerd`](#-g-and---graph-flags-on-dockerd) | v17.05 | - |
|
||||
| Deprecated | [Top-level network properties in NetworkSettings](#top-level-network-properties-in-networksettings) | v1.13 | v17.12 |
|
||||
| Removed | [`filter` param for `/images/json` endpoint](#filter-param-for-imagesjson-endpoint) | v1.13 | v20.10 |
|
||||
| Removed | [`repository:shortid` image references](#repositoryshortid-image-references) | v1.13 | v17.12 |
|
||||
| Removed | [`docker daemon` subcommand](#docker-daemon-subcommand) | v1.13 | v17.12 |
|
||||
| Removed | [Duplicate keys with conflicting values in engine labels](#duplicate-keys-with-conflicting-values-in-engine-labels) | v1.13 | v17.12 |
|
||||
| Deprecated | [`MAINTAINER` in Dockerfile](#maintainer-in-dockerfile) | v1.13 | - |
|
||||
| Deprecated | [API calls without a version](#api-calls-without-a-version) | v1.13 | v17.12 |
|
||||
| Removed | [Backing filesystem without `d_type` support for overlay/overlay2](#backing-filesystem-without-d_type-support-for-overlayoverlay2) | v1.13 | v17.12 |
|
||||
| Removed | [`--automated` and `--stars` flags on `docker search`](#--automated-and---stars-flags-on-docker-search) | v1.12 | v20.10 |
|
||||
| Deprecated | [`-h` shorthand for `--help`](#-h-shorthand-for---help) | v1.12 | v17.09 |
|
||||
| Removed | [`-e` and `--email` flags on `docker login`](#-e-and---email-flags-on-docker-login) | v1.11 | v17.06 |
|
||||
| Deprecated | [Separator (`:`) of `--security-opt` flag on `docker run`](#separator--of---security-opt-flag-on-docker-run) | v1.11 | v17.06 |
|
||||
| Deprecated | [Ambiguous event fields in API](#ambiguous-event-fields-in-api) | v1.10 | - |
|
||||
| Removed | [`-f` flag on `docker tag`](#-f-flag-on-docker-tag) | v1.10 | v1.12 |
|
||||
| Removed | [HostConfig at API container start](#hostconfig-at-api-container-start) | v1.10 | v1.12 |
|
||||
| Removed | [`--before` and `--since` flags on `docker ps`](#--before-and---since-flags-on-docker-ps) | v1.10 | v1.12 |
|
||||
| Removed | [Driver-specific log tags](#driver-specific-log-tags) | v1.9 | v1.12 |
|
||||
| Removed | [Docker Content Trust `ENV` passphrase variables name change](#docker-content-trust-env-passphrase-variables-name-change) | v1.9 | v1.12 |
|
||||
| Removed | [`/containers/(id or name)/copy` endpoint](#containersid-or-namecopy-endpoint) | v1.8 | v1.12 |
|
||||
| Removed | [LXC built-in exec driver](#lxc-built-in-exec-driver) | v1.8 | v1.10 |
|
||||
| Removed | [Old Command Line Options](#old-command-line-options) | v1.8 | v1.10 |
|
||||
| Removed | [`--api-enable-cors` flag on `dockerd`](#--api-enable-cors-flag-on-dockerd) | v1.6 | v17.09 |
|
||||
| Removed | [`--run` flag on `docker commit`](#--run-flag-on-docker-commit) | v0.10 | v1.13 |
|
||||
| Removed | [Three arguments form in `docker import`](#three-arguments-form-in-docker-import) | v0.6.7 | v1.12 |
|
||||
|
||||
### Support for encrypted TLS private keys
|
||||
|
||||
@ -254,6 +256,21 @@ Users that want to use this feature are encouraged to enable BuildKit by setting
|
||||
the `DOCKER_BUILDKIT=1` environment variable or through the daemon or CLI configuration
|
||||
files.
|
||||
|
||||
### `fluentd-async-connect` log opt
|
||||
|
||||
**Deprecated in Release: v20.10**
|
||||
|
||||
The `--log-opt fluentd-async-connect` option for the fluentd logging driver is
|
||||
[deprecated in favor of `--log-opt fluentd-async`](https://github.com/moby/moby/pull/39086).
|
||||
A deprecation message is logged in the daemon logs if the old option is used:
|
||||
|
||||
```console
|
||||
fluent#New: AsyncConnect is now deprecated, please use Async instead
|
||||
```
|
||||
|
||||
Users are encouraged to use the `fluentd-async` option going forward, as support
|
||||
for the old option will be removed in a future release.
|
||||
|
||||
### Pushing and pulling with image manifest v2 schema 1
|
||||
|
||||
**Deprecated in Release: v19.03**
|
||||
@ -307,6 +324,19 @@ format, support for the DAB file format and the top-level docker deploy command
|
||||
(hidden by default in 19.03), will be removed, in favour of `docker stack deploy`
|
||||
using compose files.
|
||||
|
||||
### Support for the `overlay2.override_kernel_check` storage option
|
||||
|
||||
**Deprecated in Release: v19.03**
|
||||
**Disabled in Release: v19.03**
|
||||
|
||||
This daemon configuration option disabled the Linux kernel version check used
|
||||
to detect if the kernel supported OverlayFS with multiple lower dirs, which is
|
||||
required for the overlay2 storage driver. Starting with Docker v19.03.7, the
|
||||
detection was improved to no longer depend on the kernel _version_, so this
|
||||
option was no longer used.
|
||||
|
||||
Docker v22.06 logs a warning in the daemon logs if this option is set, and
|
||||
users should remove this option from their daemon configuration.
|
||||
|
||||
### AuFS storage driver
|
||||
|
||||
@ -588,9 +618,9 @@ Log tags are now generated in a standard way across different logging drivers.
|
||||
Because of which, the driver specific log tag options `syslog-tag`, `gelf-tag` and
|
||||
`fluentd-tag` have been deprecated in favor of the generic `tag` option.
|
||||
|
||||
```bash
|
||||
```console
|
||||
{% raw %}
|
||||
docker --log-driver=syslog --log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}"
|
||||
$ docker --log-driver=syslog --log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}"
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
|
||||
@ -14,9 +14,9 @@ keywords: "API, Usage, plugins, documentation, developer"
|
||||
|
||||
# Docker Engine managed plugin system
|
||||
|
||||
* [Installing and using a plugin](index.md#installing-and-using-a-plugin)
|
||||
* [Developing a plugin](index.md#developing-a-plugin)
|
||||
* [Debugging plugins](index.md#debugging-plugins)
|
||||
- [Installing and using a plugin](index.md#installing-and-using-a-plugin)
|
||||
- [Developing a plugin](index.md#developing-a-plugin)
|
||||
- [Debugging plugins](index.md#debugging-plugins)
|
||||
|
||||
Docker Engine's plugin system allows you to install, start, stop, and remove
|
||||
plugins using Docker Engine.
|
||||
@ -55,7 +55,7 @@ enabled, and use it to create a volume.
|
||||
|
||||
1. Install the `sshfs` plugin.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker plugin install vieux/sshfs
|
||||
|
||||
Plugin "vieux/sshfs" is requesting the following privileges:
|
||||
@ -70,11 +70,11 @@ enabled, and use it to create a volume.
|
||||
|
||||
- It needs access to the `host` network.
|
||||
- It needs the `CAP_SYS_ADMIN` capability, which allows the plugin to run
|
||||
the `mount` command.
|
||||
the `mount` command.
|
||||
|
||||
2. Check that the plugin is enabled in the output of `docker plugin ls`.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker plugin ls
|
||||
|
||||
ID NAME TAG DESCRIPTION ENABLED
|
||||
@ -87,7 +87,7 @@ enabled, and use it to create a volume.
|
||||
|
||||
This volume can now be mounted into containers.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker volume create \
|
||||
-d vieux/sshfs \
|
||||
--name sshvolume \
|
||||
@ -96,9 +96,10 @@ enabled, and use it to create a volume.
|
||||
|
||||
sshvolume
|
||||
```
|
||||
|
||||
4. Verify that the volume was created successfully.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker volume ls
|
||||
|
||||
DRIVER NAME
|
||||
@ -107,34 +108,36 @@ enabled, and use it to create a volume.
|
||||
|
||||
5. Start a container that uses the volume `sshvolume`.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker run --rm -v sshvolume:/data busybox ls /data
|
||||
|
||||
<content of /remote on machine 1.2.3.4>
|
||||
```
|
||||
|
||||
6. Remove the volume `sshvolume`
|
||||
```bash
|
||||
docker volume rm sshvolume
|
||||
|
||||
```console
|
||||
$ docker volume rm sshvolume
|
||||
|
||||
sshvolume
|
||||
```
|
||||
|
||||
To disable a plugin, use the `docker plugin disable` command. To completely
|
||||
remove it, use the `docker plugin remove` command. For other available
|
||||
commands and options, see the
|
||||
[command line reference](https://docs.docker.com/engine/reference/commandline/cli/).
|
||||
|
||||
|
||||
## Developing a plugin
|
||||
|
||||
#### The rootfs directory
|
||||
|
||||
The `rootfs` directory represents the root filesystem of the plugin. In this
|
||||
example, it was created from a Dockerfile:
|
||||
|
||||
>**Note:** The `/run/docker/plugins` directory is mandatory inside of the
|
||||
plugin's filesystem for docker to communicate with the plugin.
|
||||
> **Note:** The `/run/docker/plugins` directory is mandatory inside of the
|
||||
> plugin's filesystem for docker to communicate with the plugin.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ git clone https://github.com/vieux/docker-volume-sshfs
|
||||
$ cd docker-volume-sshfs
|
||||
$ docker build -t rootfsimage .
|
||||
@ -153,19 +156,19 @@ Consider the following `config.json` file.
|
||||
|
||||
```json
|
||||
{
|
||||
"description": "sshFS plugin for Docker",
|
||||
"documentation": "https://docs.docker.com/engine/extend/plugins/",
|
||||
"entrypoint": ["/docker-volume-sshfs"],
|
||||
"network": {
|
||||
"type": "host"
|
||||
},
|
||||
"interface" : {
|
||||
"types": ["docker.volumedriver/1.0"],
|
||||
"socket": "sshfs.sock"
|
||||
},
|
||||
"linux": {
|
||||
"capabilities": ["CAP_SYS_ADMIN"]
|
||||
}
|
||||
"description": "sshFS plugin for Docker",
|
||||
"documentation": "https://docs.docker.com/engine/extend/plugins/",
|
||||
"entrypoint": ["/docker-volume-sshfs"],
|
||||
"network": {
|
||||
"type": "host"
|
||||
},
|
||||
"interface": {
|
||||
"types": ["docker.volumedriver/1.0"],
|
||||
"socket": "sshfs.sock"
|
||||
},
|
||||
"linux": {
|
||||
"capabilities": ["CAP_SYS_ADMIN"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -185,7 +188,6 @@ After that the plugin `<plugin-name>` will show up in `docker plugin ls`.
|
||||
Plugins can be pushed to remote registries with
|
||||
`docker plugin push <plugin-name>`.
|
||||
|
||||
|
||||
## Debugging plugins
|
||||
|
||||
Stdout of a plugin is redirected to dockerd logs. Such entries have a
|
||||
@ -193,13 +195,13 @@ Stdout of a plugin is redirected to dockerd logs. Such entries have a
|
||||
`f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62` and their
|
||||
corresponding log entries in the docker daemon logs.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker plugin install tiborvass/sample-volume-plugin
|
||||
|
||||
INFO[0036] Starting... Found 0 volumes on startup plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker volume create -d tiborvass/sample-volume-plugin samplevol
|
||||
|
||||
INFO[0193] Create Called... Ensuring directory /data/samplevol exists on host... plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
@ -208,7 +210,7 @@ INFO[0193] Created volume samplevol with mountpoint /data/samp
|
||||
INFO[0193] Path Called... Returned path /data/samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker run -v samplevol:/tmp busybox sh
|
||||
|
||||
INFO[0421] Get Called... Found samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
@ -223,8 +225,8 @@ INFO[0421] Unmount Called... Unmounted samplevol plugin=f52a3df433b9a
|
||||
plugins. This is specifically useful to collect plugin logs if they are
|
||||
redirected to a file.
|
||||
|
||||
```bash
|
||||
$ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins list
|
||||
```console
|
||||
$ sudo runc --root /run/docker/runtime-runc/plugins.moby list
|
||||
|
||||
ID PID STATUS BUNDLE CREATED OWNER
|
||||
93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 15806 running /run/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby-plugins/93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 2018-02-08T21:40:08.621358213Z root
|
||||
@ -232,14 +234,15 @@ ID PID S
|
||||
c5bb4b90941efcaccca999439ed06d6a6affdde7081bb34dc84126b57b3e793d 14984 running /run/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby-plugins/c5bb4b90941efcaccca999439ed06d6a6affdde7081bb34dc84126b57b3e793d 2018-02-08T21:35:12.321288966Z root
|
||||
```
|
||||
|
||||
```bash
|
||||
$ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins exec 93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 cat /var/log/plugin.log
|
||||
```console
|
||||
$ sudo runc --root /run/docker/runtime-runc/plugins.moby exec 93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 cat /var/log/plugin.log
|
||||
```
|
||||
|
||||
If the plugin has a built-in shell, then exec into the plugin can be done as
|
||||
follows:
|
||||
```bash
|
||||
$ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins exec -t 93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 sh
|
||||
|
||||
```console
|
||||
$ sudo runc --root /run/docker/runtime-runc/plugins.moby exec -t 93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 sh
|
||||
```
|
||||
|
||||
#### Using curl to debug plugin socket issues.
|
||||
@ -250,18 +253,18 @@ docker host to volume and network plugins using curl 7.47.0 to ensure that
|
||||
the plugin is listening on the said socket. For a well functioning plugin,
|
||||
these basic requests should work. Note that plugin sockets are available on the host under `/var/run/docker/plugins/<pluginID>`
|
||||
|
||||
|
||||
```bash
|
||||
curl -H "Content-Type: application/json" -XPOST -d '{}' --unix-socket /var/run/docker/plugins/e8a37ba56fc879c991f7d7921901723c64df6b42b87e6a0b055771ecf8477a6d/plugin.sock http:/VolumeDriver.List
|
||||
```console
|
||||
$ curl -H "Content-Type: application/json" -XPOST -d '{}' --unix-socket /var/run/docker/plugins/e8a37ba56fc879c991f7d7921901723c64df6b42b87e6a0b055771ecf8477a6d/plugin.sock http:/VolumeDriver.List
|
||||
|
||||
{"Mountpoint":"","Err":"","Volumes":[{"Name":"myvol1","Mountpoint":"/data/myvol1"},{"Name":"myvol2","Mountpoint":"/data/myvol2"}],"Volume":null}
|
||||
```
|
||||
|
||||
```bash
|
||||
curl -H "Content-Type: application/json" -XPOST -d '{}' --unix-socket /var/run/docker/plugins/45e00a7ce6185d6e365904c8bcf62eb724b1fe307e0d4e7ecc9f6c1eb7bcdb70/plugin.sock http:/NetworkDriver.GetCapabilities
|
||||
```console
|
||||
$ curl -H "Content-Type: application/json" -XPOST -d '{}' --unix-socket /var/run/docker/plugins/45e00a7ce6185d6e365904c8bcf62eb724b1fe307e0d4e7ecc9f6c1eb7bcdb70/plugin.sock http:/NetworkDriver.GetCapabilities
|
||||
|
||||
{"Scope":"local"}
|
||||
```
|
||||
|
||||
When using curl 7.5 and above, the URL should be of the form
|
||||
`http://hostname/APICall`, where `hostname` is the valid hostname where the
|
||||
plugin is installed and `APICall` is the call to the plugin API.
|
||||
|
||||
@ -72,15 +72,15 @@ The sections below provide an inexhaustive overview of available plugins.
|
||||
| [Horcrux Volume Plugin](https://github.com/muthu-r/horcrux) | A volume plugin that allows on-demand, version controlled access to your data. Horcrux is an open-source plugin, written in Go, and supports SCP, [Minio](https://www.minio.io) and Amazon S3. |
|
||||
| [HPE 3Par Volume Plugin](https://github.com/hpe-storage/python-hpedockerplugin/) | A volume plugin that supports HPE 3Par and StoreVirtual iSCSI storage arrays. |
|
||||
| [Infinit volume plugin](https://infinit.sh/documentation/docker/volume-plugin) | A volume plugin that makes it easy to mount and manage Infinit volumes using Docker. |
|
||||
| [IPFS Volume Plugin](http://github.com/vdemeester/docker-volume-ipfs) | An open source volume plugin that allows using an [ipfs](https://ipfs.io/) filesystem as a volume. |
|
||||
| [IPFS Volume Plugin](https://github.com/vdemeester/docker-volume-ipfs) | An open source volume plugin that allows using an [ipfs](https://ipfs.io/) filesystem as a volume. |
|
||||
| [Keywhiz plugin](https://github.com/calavera/docker-volume-keywhiz) | A plugin that provides credentials and secret management using Keywhiz as a central repository. |
|
||||
| [Local Persist Plugin](https://github.com/CWSpear/local-persist) | A volume plugin that extends the default `local` driver's functionality by allowing you specify a mountpoint anywhere on the host, which enables the files to *always persist*, even if the volume is removed via `docker volume rm`. |
|
||||
| [NetApp Plugin](https://github.com/NetApp/netappdvp) (nDVP) | A volume plugin that provides direct integration with the Docker ecosystem for the NetApp storage portfolio. The nDVP package supports the provisioning and management of storage resources from the storage platform to Docker hosts, with a robust framework for adding additional platforms in the future. |
|
||||
| [Netshare plugin](https://github.com/ContainX/docker-volume-netshare) | A volume plugin that provides volume management for NFS 3/4, AWS EFS and CIFS file systems. |
|
||||
| [Nimble Storage Volume Plugin](https://connect.nimblestorage.com/community/app-integration/docker) | A volume plug-in that integrates with Nimble Storage Unified Flash Fabric arrays. The plug-in abstracts array volume capabilities to the Docker administrator to allow self-provisioning of secure multi-tenant volumes and clones. |
|
||||
| [Nimble Storage Volume Plugin](https://scod.hpedev.io/docker_volume_plugins/hpe_nimble_storage/index.html) | A volume plug-in that integrates with Nimble Storage Unified Flash Fabric arrays. The plug-in abstracts array volume capabilities to the Docker administrator to allow self-provisioning of secure multi-tenant volumes and clones. |
|
||||
| [OpenStorage Plugin](https://github.com/libopenstorage/openstorage) | A cluster-aware volume plugin that provides volume management for file and block storage solutions. It implements a vendor neutral specification for implementing extensions such as CoS, encryption, and snapshots. It has example drivers based on FUSE, NFS, NBD and EBS to name a few. |
|
||||
| [Portworx Volume Plugin](https://github.com/portworx/px-dev) | A volume plugin that turns any server into a scale-out converged compute/storage node, providing container granular storage and highly available volumes across any node, using a shared-nothing storage backend that works with any docker scheduler. |
|
||||
| [Quobyte Volume Plugin](https://github.com/quobyte/docker-volume) | A volume plugin that connects Docker to [Quobyte](http://www.quobyte.com/containers)'s data center file system, a general-purpose scalable and fault-tolerant storage platform. |
|
||||
| [Quobyte Volume Plugin](https://github.com/quobyte/docker-volume) | A volume plugin that connects Docker to [Quobyte](https://www.quobyte.com/containers)'s data center file system, a general-purpose scalable and fault-tolerant storage platform. |
|
||||
| [REX-Ray plugin](https://github.com/emccode/rexray) | A volume plugin which is written in Go and provides advanced storage functionality for many platforms including VirtualBox, EC2, Google Compute Engine, OpenStack, and EMC. |
|
||||
| [Virtuozzo Storage and Ploop plugin](https://github.com/virtuozzo/docker-volume-ploop) | A volume plugin with support for Virtuozzo Storage distributed cloud file system as well as ploop devices. |
|
||||
| [VMware vSphere Storage Plugin](https://github.com/vmware/docker-volume-vsphere) | Docker Volume Driver for vSphere enables customers to address persistent storage requirements for Docker containers in vSphere environments. |
|
||||
|
||||
@ -90,7 +90,7 @@ The `TLSConfig` field is optional and TLS will only be verified if this configur
|
||||
Plugins should be started before Docker, and stopped after Docker. For
|
||||
example, when packaging a plugin for a platform which supports `systemd`, you
|
||||
might use [`systemd` dependencies](
|
||||
http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before=) to
|
||||
https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before=) to
|
||||
manage startup and shutdown order.
|
||||
|
||||
When upgrading a plugin, you should first stop the Docker daemon, upgrade the
|
||||
@ -114,7 +114,7 @@ a `service` file and a `socket` file.
|
||||
|
||||
The `service` file (for example `/lib/systemd/system/your-plugin.service`):
|
||||
|
||||
```
|
||||
```systemd
|
||||
[Unit]
|
||||
Description=Your plugin
|
||||
Before=docker.service
|
||||
@ -127,9 +127,10 @@ ExecStart=/usr/lib/docker/your-plugin
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
The `socket` file (for example `/lib/systemd/system/your-plugin.socket`):
|
||||
|
||||
```
|
||||
```systemd
|
||||
[Unit]
|
||||
Description=Your plugin
|
||||
|
||||
@ -166,7 +167,8 @@ Plugins are activated via the following "handshake" API call.
|
||||
**Request:** empty body
|
||||
|
||||
**Response:**
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"Implements": ["VolumeDriver"]
|
||||
}
|
||||
|
||||
@ -114,9 +114,9 @@ Enable the authorization plugin with a dedicated command line flag in the
|
||||
`--authorization-plugin=PLUGIN_ID` format. The flag supplies a `PLUGIN_ID`
|
||||
value. This value can be the plugin’s socket or a path to a specification file.
|
||||
Authorization plugins can be loaded without restarting the daemon. Refer
|
||||
to the [`dockerd` documentation](../reference/commandline/dockerd.md#configuration-reloading) for more information.
|
||||
to the [`dockerd` documentation](../reference/commandline/dockerd.md#configuration-reload-behavior) for more information.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ dockerd --authorization-plugin=plugin1 --authorization-plugin=plugin2,...
|
||||
```
|
||||
|
||||
@ -124,26 +124,26 @@ Docker's authorization subsystem supports multiple `--authorization-plugin` para
|
||||
|
||||
### Calling authorized command (allow)
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker pull centos
|
||||
...
|
||||
<...>
|
||||
f1b10cd84249: Pull complete
|
||||
...
|
||||
<...>
|
||||
```
|
||||
|
||||
### Calling unauthorized command (deny)
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker pull centos
|
||||
...
|
||||
<...>
|
||||
docker: Error response from daemon: authorization denied by plugin PLUGIN_NAME: volumes are not allowed.
|
||||
```
|
||||
|
||||
### Error from plugins
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker pull centos
|
||||
...
|
||||
<...>
|
||||
docker: Error response from daemon: plugin PLUGIN_NAME failed with error: AuthZPlugin.AuthZReq: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
|
||||
```
|
||||
|
||||
@ -180,6 +180,7 @@ should implement the following two methods:
|
||||
"Err": "The error message if things go wrong"
|
||||
}
|
||||
```
|
||||
|
||||
#### /AuthZPlugin.AuthZRes
|
||||
|
||||
**Request**:
|
||||
|
||||
@ -31,7 +31,7 @@ You need to install and enable the plugin and then restart the Docker daemon
|
||||
before using the plugin. See the following example for the correct ordering
|
||||
of steps.
|
||||
|
||||
```
|
||||
```console
|
||||
$ docker plugin install cpuguy83/docker-overlay2-graphdriver-plugin # this command also enables the driver
|
||||
<output suppressed>
|
||||
$ pkill dockerd
|
||||
@ -309,6 +309,7 @@ Get an archive of the changes between the filesystem layers specified by the `ID
|
||||
and `Parent`. `Parent` may be an empty string, in which case there is no parent.
|
||||
|
||||
**Response**:
|
||||
|
||||
```
|
||||
{% raw %}
|
||||
{{ TAR STREAM }}
|
||||
@ -354,6 +355,7 @@ Respond with a non-empty string error if an error occurred.
|
||||
### /GraphDriver.ApplyDiff
|
||||
|
||||
**Request**:
|
||||
|
||||
```
|
||||
{% raw %}
|
||||
{{ TAR STREAM }}
|
||||
|
||||
@ -211,6 +211,7 @@ as they come in once the existing logs have been read.
|
||||
to determine what set of logs to read.
|
||||
|
||||
**Response**:
|
||||
|
||||
```
|
||||
{% raw %}{{ log stream }}{% endraw %}
|
||||
```
|
||||
|
||||
@ -42,7 +42,7 @@ Once running however, network driver plugins are used just like the built-in
|
||||
network drivers: by being mentioned as a driver in network-oriented Docker
|
||||
commands. For example,
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker network create --driver weave mynet
|
||||
```
|
||||
|
||||
@ -51,7 +51,7 @@ Some network driver plugins are listed in [plugins](legacy_plugins.md)
|
||||
The `mynet` network is now owned by `weave`, so subsequent commands
|
||||
referring to that network will be sent to the plugin,
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker run --network=mynet busybox top
|
||||
```
|
||||
|
||||
|
||||
@ -29,20 +29,20 @@ node1 is the manager and node2 is the worker.
|
||||
|
||||
1. Prepare manager. In node 1:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker swarm init
|
||||
Swarm initialized: current node (dxn1zf6l61qsb1josjja83ngz) is now a manager.
|
||||
```
|
||||
|
||||
2. Join swarm, install plugin and create volume on worker. In node 2:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker swarm join \
|
||||
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
|
||||
192.168.99.100:2377
|
||||
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
|
||||
192.168.99.100:2377
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker plugin install tiborvass/sample-volume-plugin
|
||||
latest: Pulling from tiborvass/sample-volume-plugin
|
||||
eb9c16fbdc53: Download complete
|
||||
@ -51,23 +51,24 @@ node1 is the manager and node2 is the worker.
|
||||
Installed plugin tiborvass/sample-volume-plugin
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker volume create -d tiborvass/sample-volume-plugin --name pluginVol
|
||||
```
|
||||
|
||||
3. Create a service using the plugin and volume. In node1:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker service create --name my-service --mount type=volume,volume-driver=tiborvass/sample-volume-plugin,source=pluginVol,destination=/tmp busybox top
|
||||
|
||||
$ docker service ls
|
||||
z1sj8bb8jnfn my-service replicated 1/1 busybox:latest
|
||||
```
|
||||
docker service ls shows service 1 instance of service running.
|
||||
|
||||
`docker service ls` shows service 1 instance of service running.
|
||||
|
||||
4. Observe the task getting scheduled in node 2:
|
||||
|
||||
```bash
|
||||
```console
|
||||
{% raw %}
|
||||
$ docker ps --format '{{.ID}}\t {{.Status}} {{.Names}} {{.Command}}'
|
||||
83fc1e842599 Up 2 days my-service.1.9jn59qzn7nbc3m0zt1hij12xs "top"
|
||||
@ -87,7 +88,7 @@ Note that node1 is the manager and node2 is the worker.
|
||||
1. Install a global scoped network plugin on both manager and worker. On node1
|
||||
and node2:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker plugin install bboreham/weave2
|
||||
Plugin "bboreham/weave2" is requesting the following privileges:
|
||||
- network: [host]
|
||||
@ -102,7 +103,7 @@ Note that node1 is the manager and node2 is the worker.
|
||||
|
||||
2. Create a network using plugin on manager. On node1:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker network create --driver=bboreham/weave2:latest globalnet
|
||||
|
||||
$ docker network ls
|
||||
@ -115,12 +116,12 @@ containers get scheduled on both manager and worker.
|
||||
|
||||
On node 1:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker service create --network globalnet --name myservice --replicas=8 mrjana/simpleweb simpleweb
|
||||
w90drnfzw85nygbie9kb89vpa
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker ps
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
87520965206a mrjana/simpleweb@sha256:317d7f221d68c86d503119b0ea12c29de42af0a22ca087d522646ad1069a47a4 "simpleweb" 5 seconds ago Up 4 seconds myservice.4.ytdzpktmwor82zjxkh118uf1v
|
||||
@ -131,7 +132,7 @@ w90drnfzw85nygbie9kb89vpa
|
||||
|
||||
On node 2:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker ps
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
53c0ae7c1dae mrjana/simpleweb@sha256:317d7f221d68c86d503119b0ea12c29de42af0a22ca087d522646ad1069a47a4 "simpleweb" 2 seconds ago Up Less than a second myservice.7.x44tvvdm3iwkt9kif35f7ykz1
|
||||
@ -142,14 +143,14 @@ w90drnfzw85nygbie9kb89vpa
|
||||
|
||||
4. Scale down the number of instances. On node1:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker service scale myservice=0
|
||||
myservice scaled to 0
|
||||
```
|
||||
|
||||
5. Disable and uninstall the plugin on the worker. On node2:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker plugin rm -f bboreham/weave2
|
||||
bboreham/weave2
|
||||
```
|
||||
@ -159,12 +160,12 @@ scheduled on the master and not on the worker, because the plugin is not availab
|
||||
|
||||
On node 1:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker service scale myservice=8
|
||||
myservice scaled to 8
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker ps
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
cf4b0ec2415e mrjana/simpleweb@sha256:317d7f221d68c86d503119b0ea12c29de42af0a22ca087d522646ad1069a47a4 "simpleweb" 39 seconds ago Up 36 seconds myservice.3.r7p5o208jmlzpcbm2ytl3q6n1
|
||||
@ -179,7 +180,7 @@ scheduled on the master and not on the worker, because the plugin is not availab
|
||||
|
||||
On node 2:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker ps
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
```
|
||||
|
||||
@ -54,7 +54,7 @@ flags on the `docker container run` command. The `--volume` (or `-v`) flag
|
||||
accepts a volume name and path on the host, and the `--volume-driver` flag
|
||||
accepts a driver type.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker volume create --driver=flocker volumename
|
||||
|
||||
$ docker container run -it --volume volumename:/data busybox sh
|
||||
|
||||
@ -112,7 +112,7 @@ instructions.
|
||||
|
||||
Whenever possible, Docker uses a build-cache to accelerate the `docker build`
|
||||
process significantly. This is indicated by the `CACHED` message in the console
|
||||
output. (For more information, see the [`Dockerfile` best practices guide](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/):
|
||||
output. (For more information, see the [`Dockerfile` best practices guide](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/)):
|
||||
|
||||
```console
|
||||
$ docker build -t svendowideit/ambassador .
|
||||
@ -159,8 +159,8 @@ implementation. For example, BuildKit can:
|
||||
To use the BuildKit backend, you need to set an environment variable
|
||||
`DOCKER_BUILDKIT=1` on the CLI before invoking `docker build`.
|
||||
|
||||
To learn about the experimental Dockerfile syntax available to BuildKit-based
|
||||
builds [refer to the documentation in the BuildKit repository](https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/experimental.md).
|
||||
To learn about the Dockerfile syntax available to BuildKit-based
|
||||
builds [refer to the documentation in the BuildKit repository](https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md).
|
||||
|
||||
## Format
|
||||
|
||||
@ -179,7 +179,7 @@ Docker runs instructions in a `Dockerfile` in order. A `Dockerfile` **must
|
||||
begin with a `FROM` instruction**. This may be after [parser
|
||||
directives](#parser-directives), [comments](#format), and globally scoped
|
||||
[ARGs](#arg). The `FROM` instruction specifies the [*Parent
|
||||
Image*](https://docs.docker.com/glossary/#parent_image) from which you are
|
||||
Image*](https://docs.docker.com/glossary/#parent-image) from which you are
|
||||
building. `FROM` may only be preceded by one or more `ARG` instructions, which
|
||||
declare arguments that are used in `FROM` lines in the `Dockerfile`.
|
||||
|
||||
@ -599,10 +599,10 @@ This file causes the following build behavior:
|
||||
|
||||
|
||||
Matching is done using Go's
|
||||
[filepath.Match](http://golang.org/pkg/path/filepath#Match) rules. A
|
||||
[filepath.Match](https://golang.org/pkg/path/filepath#Match) rules. A
|
||||
preprocessing step removes leading and trailing whitespace and
|
||||
eliminates `.` and `..` elements using Go's
|
||||
[filepath.Clean](http://golang.org/pkg/path/filepath/#Clean). Lines
|
||||
[filepath.Clean](https://golang.org/pkg/path/filepath/#Clean). Lines
|
||||
that are blank after preprocessing are ignored.
|
||||
|
||||
Beyond Go's filepath.Match rules, Docker also supports a special
|
||||
@ -677,7 +677,7 @@ FROM [--platform=<platform>] <image>[@<digest>] [AS <name>]
|
||||
```
|
||||
|
||||
The `FROM` instruction initializes a new build stage and sets the
|
||||
[*Base Image*](https://docs.docker.com/glossary/#base_image) for subsequent instructions. As such, a
|
||||
[*Base Image*](https://docs.docker.com/glossary/#base-image) for subsequent instructions. As such, a
|
||||
valid `Dockerfile` must start with a `FROM` instruction. The image can be
|
||||
any valid image – it is especially easy to start by **pulling an image** from
|
||||
the [*Public Repositories*](https://docs.docker.com/docker-hub/repos/).
|
||||
@ -759,6 +759,7 @@ RUN instruction onto the next line. For example, consider these two lines:
|
||||
RUN /bin/bash -c 'source $HOME/.bashrc; \
|
||||
echo $HOME'
|
||||
```
|
||||
|
||||
Together they are equivalent to this single line:
|
||||
|
||||
```dockerfile
|
||||
@ -938,6 +939,7 @@ the `--format` option to show just the labels;
|
||||
```console
|
||||
$ docker image inspect --format='{{json .Config.Labels}}' myimage
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"com.example.vendor": "ACME Incorporated",
|
||||
@ -1058,7 +1060,7 @@ If an environment variable is only needed during build, and not in the final
|
||||
image, consider setting a value for a single command instead:
|
||||
|
||||
```dockerfile
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y ...
|
||||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ...
|
||||
```
|
||||
|
||||
Or using [`ARG`](#arg), which is not persisted in the final image:
|
||||
@ -1115,7 +1117,7 @@ directories, their paths are interpreted as relative to the source of
|
||||
the context of the build.
|
||||
|
||||
Each `<src>` may contain wildcards and matching will be done using Go's
|
||||
[filepath.Match](http://golang.org/pkg/path/filepath#Match) rules. For example:
|
||||
[filepath.Match](https://golang.org/pkg/path/filepath#Match) rules. For example:
|
||||
|
||||
To add all files starting with "hom":
|
||||
|
||||
@ -1291,7 +1293,7 @@ directories will be interpreted as relative to the source of the context
|
||||
of the build.
|
||||
|
||||
Each `<src>` may contain wildcards and matching will be done using Go's
|
||||
[filepath.Match](http://golang.org/pkg/path/filepath#Match) rules. For example:
|
||||
[filepath.Match](https://golang.org/pkg/path/filepath#Match) rules. For example:
|
||||
|
||||
To add all files starting with "hom":
|
||||
|
||||
@ -1630,7 +1632,7 @@ If you forget to add `exec` to the beginning of your `ENTRYPOINT`:
|
||||
```dockerfile
|
||||
FROM ubuntu
|
||||
ENTRYPOINT top -b
|
||||
CMD --ignored-param1
|
||||
CMD -- --ignored-param1
|
||||
```
|
||||
|
||||
You can then run it (giving it a name for the next step):
|
||||
@ -1638,12 +1640,15 @@ You can then run it (giving it a name for the next step):
|
||||
```console
|
||||
$ docker run -it --name test top --ignored-param2
|
||||
|
||||
Mem: 1704184K used, 352484K free, 0K shrd, 0K buff, 140621524238337K cached
|
||||
CPU: 9% usr 2% sys 0% nic 88% idle 0% io 0% irq 0% sirq
|
||||
Load average: 0.01 0.02 0.05 2/101 7
|
||||
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
|
||||
1 0 root S 3168 0% 0% /bin/sh -c top -b cmd cmd2
|
||||
7 1 root R 3164 0% 0% top -b
|
||||
top - 13:58:24 up 17 min, 0 users, load average: 0.00, 0.00, 0.00
|
||||
Tasks: 2 total, 1 running, 1 sleeping, 0 stopped, 0 zombie
|
||||
%Cpu(s): 16.7 us, 33.3 sy, 0.0 ni, 50.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
|
||||
MiB Mem : 1990.8 total, 1354.6 free, 231.4 used, 404.7 buff/cache
|
||||
MiB Swap: 1024.0 total, 1024.0 free, 0.0 used. 1639.8 avail Mem
|
||||
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 2612 604 536 S 0.0 0.0 0:00.02 sh
|
||||
6 root 20 0 5956 3188 2768 R 0.0 0.2 0:00.00 top
|
||||
```
|
||||
|
||||
You can see from the output of `top` that the specified `ENTRYPOINT` is not `PID 1`.
|
||||
@ -1652,12 +1657,12 @@ If you then run `docker stop test`, the container will not exit cleanly - the
|
||||
`stop` command will be forced to send a `SIGKILL` after the timeout:
|
||||
|
||||
```console
|
||||
$ docker exec -it test ps aux
|
||||
$ docker exec -it test ps waux
|
||||
|
||||
PID USER COMMAND
|
||||
1 root /bin/sh -c top -b cmd cmd2
|
||||
7 root top -b
|
||||
8 root ps aux
|
||||
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
|
||||
root 1 0.4 0.0 2612 604 pts/0 Ss+ 13:58 0:00 /bin/sh -c top -b --ignored-param2
|
||||
root 6 0.0 0.1 5956 3188 pts/0 S+ 13:58 0:00 top -b
|
||||
root 7 0.0 0.1 5884 2816 pts/1 Rs+ 13:58 0:00 ps waux
|
||||
|
||||
$ /usr/bin/time docker stop test
|
||||
|
||||
@ -1822,6 +1827,11 @@ RUN pwd
|
||||
The output of the final `pwd` command in this `Dockerfile` would be
|
||||
`/path/$DIRNAME`
|
||||
|
||||
If not specified, the default working directory is `/`. In practice, if you aren't building a Dockerfile from scratch (`FROM scratch`),
|
||||
the `WORKDIR` may likely be set by the base image you're using.
|
||||
|
||||
Therefore, to avoid unintended operations in unknown directories, it is best practice to set your `WORKDIR` explicitly.
|
||||
|
||||
## ARG
|
||||
|
||||
```dockerfile
|
||||
@ -2171,9 +2181,14 @@ ONBUILD RUN /usr/local/bin/python-build --dir /app/src
|
||||
STOPSIGNAL signal
|
||||
```
|
||||
|
||||
The `STOPSIGNAL` instruction sets the system call signal that will be sent to the container to exit.
|
||||
This signal can be a valid unsigned number that matches a position in the kernel's syscall table, for instance 9,
|
||||
or a signal name in the format SIGNAME, for instance SIGKILL.
|
||||
The `STOPSIGNAL` instruction sets the system call signal that will be sent to the
|
||||
container to exit. This signal can be a signal name in the format `SIG<NAME>`,
|
||||
for instance `SIGKILL`, or an unsigned number that matches a position in the
|
||||
kernel's syscall table, for instance `9`. The default is `SIGTERM` if not
|
||||
defined.
|
||||
|
||||
The image's default stopsignal can be overridden per container, using the
|
||||
`--stop-signal` flag on `docker run` and `docker create`.
|
||||
|
||||
## HEALTHCHECK
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ containers, see [**Configuration file** section](cli.md#configuration-files).
|
||||
|
||||
### Attach to and detach from a running container
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker run -d --name topdemo ubuntu /usr/bin/top -b
|
||||
|
||||
$ docker attach topdemo
|
||||
@ -130,22 +130,19 @@ $ docker ps -a | grep topdemo
|
||||
And in this second example, you can see the exit code returned by the `bash`
|
||||
process is returned by the `docker attach` command to its caller too:
|
||||
|
||||
```bash
|
||||
$ docker run --name test -d -it debian
|
||||
```console
|
||||
$ docker run --name test -d -it debian
|
||||
275c44472aebd77c926d4527885bb09f2f6db21d878c75f0a1c212c03d3bcfab
|
||||
|
||||
275c44472aebd77c926d4527885bb09f2f6db21d878c75f0a1c212c03d3bcfab
|
||||
$ docker attach test
|
||||
root@f38c87f2a42d:/# exit 13
|
||||
|
||||
$ docker attach test
|
||||
exit
|
||||
|
||||
root@f38c87f2a42d:/# exit 13
|
||||
$ echo $?
|
||||
13
|
||||
|
||||
exit
|
||||
$ docker ps -a | grep test
|
||||
|
||||
$ echo $?
|
||||
|
||||
13
|
||||
|
||||
$ docker ps -a | grep test
|
||||
|
||||
275c44472aeb debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test
|
||||
275c44472aeb debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test
|
||||
```
|
||||
|
||||
@ -92,23 +92,23 @@ context.
|
||||
For example, run this command to use a directory called `docker` in the branch
|
||||
`container`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build https://github.com/docker/rootfs.git#container:docker
|
||||
```
|
||||
|
||||
The following table represents all the valid suffixes with their build
|
||||
contexts:
|
||||
|
||||
Build Syntax Suffix | Commit Used | Build Context Used
|
||||
--------------------------------|-----------------------|-------------------
|
||||
`myrepo.git` | `refs/heads/master` | `/`
|
||||
`myrepo.git#mytag` | `refs/tags/mytag` | `/`
|
||||
`myrepo.git#mybranch` | `refs/heads/mybranch` | `/`
|
||||
`myrepo.git#pull/42/head` | `refs/pull/42/head` | `/`
|
||||
`myrepo.git#:myfolder` | `refs/heads/master` | `/myfolder`
|
||||
`myrepo.git#master:myfolder` | `refs/heads/master` | `/myfolder`
|
||||
`myrepo.git#mytag:myfolder` | `refs/tags/mytag` | `/myfolder`
|
||||
`myrepo.git#mybranch:myfolder` | `refs/heads/mybranch` | `/myfolder`
|
||||
| Build Syntax Suffix | Commit Used | Build Context Used |
|
||||
|--------------------------------|-----------------------|--------------------|
|
||||
| `myrepo.git` | `refs/heads/master` | `/` |
|
||||
| `myrepo.git#mytag` | `refs/tags/mytag` | `/` |
|
||||
| `myrepo.git#mybranch` | `refs/heads/mybranch` | `/` |
|
||||
| `myrepo.git#pull/42/head` | `refs/pull/42/head` | `/` |
|
||||
| `myrepo.git#:myfolder` | `refs/heads/master` | `/myfolder` |
|
||||
| `myrepo.git#master:myfolder` | `refs/heads/master` | `/myfolder` |
|
||||
| `myrepo.git#mytag:myfolder` | `refs/tags/mytag` | `/myfolder` |
|
||||
| `myrepo.git#mybranch:myfolder` | `refs/heads/mybranch` | `/myfolder` |
|
||||
|
||||
> **Note**
|
||||
>
|
||||
@ -120,7 +120,7 @@ Build Syntax Suffix | Commit Used | Build Context Used
|
||||
|
||||
If you pass an URL to a remote tarball, the URL itself is sent to the daemon:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build http://server/context.tar.gz
|
||||
```
|
||||
|
||||
@ -136,7 +136,7 @@ build context. Tarball contexts must be tar archives conforming to the standard
|
||||
Instead of specifying a context, you can pass a single `Dockerfile` in the
|
||||
`URL` or pipe the file in via `STDIN`. To pipe a `Dockerfile` from `STDIN`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build - < Dockerfile
|
||||
```
|
||||
|
||||
@ -176,7 +176,7 @@ build fails, a non-zero failure code will be returned.
|
||||
There should be informational output of the reason for failure output to
|
||||
`STDERR`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build -t fail .
|
||||
|
||||
Sending build context to Docker daemon 2.048 kB
|
||||
@ -198,7 +198,7 @@ See also:
|
||||
|
||||
### Build with PATH
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build .
|
||||
|
||||
Uploading context 10240 bytes
|
||||
@ -243,7 +243,7 @@ you must use `--rm=false`. This does not affect the build cache.
|
||||
|
||||
### Build with URL
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build github.com/creack/docker-firefox
|
||||
```
|
||||
|
||||
@ -251,7 +251,7 @@ This will clone the GitHub repository and use the cloned repository as context.
|
||||
The Dockerfile at the root of the repository is used as Dockerfile. You can
|
||||
specify an arbitrary Git repository by using the `git://` or `git@` scheme.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build -f ctx/Dockerfile http://server/ctx.tar.gz
|
||||
|
||||
Downloading context: http://server/ctx.tar.gz [===================>] 240 B/240 B
|
||||
@ -277,7 +277,7 @@ ctx/container.cfg /` operation works as expected.
|
||||
|
||||
### Build with -
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build - < Dockerfile
|
||||
```
|
||||
|
||||
@ -286,7 +286,7 @@ context, no contents of any local directory will be sent to the Docker daemon.
|
||||
Since there is no context, a Dockerfile `ADD` only works if it refers to a
|
||||
remote URL.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build - < context.tar.gz
|
||||
```
|
||||
|
||||
@ -295,7 +295,7 @@ formats are: bzip2, gzip and xz.
|
||||
|
||||
### Use a .dockerignore file
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build .
|
||||
|
||||
Uploading context 18.829 MB
|
||||
@ -323,18 +323,18 @@ directory from the context. Its effect can be seen in the changed size of the
|
||||
uploaded context. The builder reference contains detailed information on
|
||||
[creating a .dockerignore file](../builder.md#dockerignore-file).
|
||||
|
||||
When using the [BuildKit backend](../builder.md#buildkit), `docker build` searches
|
||||
for a `.dockerignore` file relative to the Dockerfile name. For example, running
|
||||
`docker build -f myapp.Dockerfile .` will first look for an ignore file named
|
||||
`myapp.Dockerfile.dockerignore`. If such a file is not found, the `.dockerignore`
|
||||
file is used if present. Using a Dockerfile based `.dockerignore` is useful if a
|
||||
project contains multiple Dockerfiles that expect to ignore different sets of
|
||||
files.
|
||||
When using the [BuildKit backend](https://docs.docker.com/build/buildkit/),
|
||||
`docker build` searches for a `.dockerignore` file relative to the Dockerfile
|
||||
name. For example, running `docker build -f myapp.Dockerfile .` will first look
|
||||
for an ignore file named `myapp.Dockerfile.dockerignore`. If such a file is not
|
||||
found, the `.dockerignore` file is used if present. Using a Dockerfile based
|
||||
`.dockerignore` is useful if a project contains multiple Dockerfiles that
|
||||
expect to ignore different sets of files.
|
||||
|
||||
|
||||
### Tag an image (-t)
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build -t vieux/apache:2.0 .
|
||||
```
|
||||
|
||||
@ -348,27 +348,27 @@ version.
|
||||
For example, to tag an image both as `whenry/fedora-jboss:latest` and
|
||||
`whenry/fedora-jboss:v2.1`, use the following:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .
|
||||
```
|
||||
|
||||
### Specify a Dockerfile (-f)
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build -f Dockerfile.debug .
|
||||
```
|
||||
|
||||
This will use a file called `Dockerfile.debug` for the build instructions
|
||||
instead of `Dockerfile`.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ curl example.com/remote/Dockerfile | docker build -f - .
|
||||
```
|
||||
|
||||
The above command will use the current directory as the build context and read
|
||||
a Dockerfile from stdin.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build -f dockerfiles/Dockerfile.debug -t myapp_debug .
|
||||
$ docker build -f dockerfiles/Dockerfile.prod -t myapp_prod .
|
||||
```
|
||||
@ -377,7 +377,7 @@ The above commands will build the current build context (as specified by the
|
||||
`.`) twice, once using a debug version of a `Dockerfile` and once using a
|
||||
production version.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ cd /home/me/myapp/some/dir/really/deep
|
||||
$ docker build -f /home/me/myapp/dockerfiles/debug /home/me/myapp
|
||||
$ docker build -f ../../../../dockerfiles/debug /home/me/myapp
|
||||
@ -420,7 +420,7 @@ A good example is `http_proxy` or source versions for pulling intermediate
|
||||
files. The `ARG` instruction lets Dockerfile authors define values that users
|
||||
can set at build-time using the `--build-arg` flag:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build --build-arg HTTP_PROXY=http://10.20.30.2:1234 --build-arg FTP_PROXY=http://40.50.60.5:4567 .
|
||||
```
|
||||
|
||||
@ -439,7 +439,7 @@ You may also use the `--build-arg` flag without a value, in which case the value
|
||||
from the local environment will be propagated into the Docker container being
|
||||
built:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ export HTTP_PROXY=http://10.20.30.2:1234
|
||||
$ docker build --build-arg HTTP_PROXY .
|
||||
```
|
||||
@ -461,11 +461,11 @@ technology. On Linux, the only supported is the `default` option which uses
|
||||
Linux namespaces. On Microsoft Windows, you can specify these values:
|
||||
|
||||
|
||||
| Value | Description |
|
||||
|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `default` | Use the value specified by the Docker daemon's `--exec-opt` . If the `daemon` does not specify an isolation technology, Microsoft Windows uses `process` as its default value. |
|
||||
| `process` | Namespace isolation only. |
|
||||
| `hyperv` | Hyper-V hypervisor partition-based isolation. |
|
||||
| Value | Description |
|
||||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `default` | Use the value specified by the Docker daemon's `--exec-opt` . If the `daemon` does not specify an isolation technology, Microsoft Windows uses `process` as its default value. |
|
||||
| `process` | Namespace isolation only. |
|
||||
| `hyperv` | Hyper-V hypervisor partition-based isolation. |
|
||||
|
||||
Specifying the `--isolation` flag without a value is the same as setting `--isolation="default"`.
|
||||
|
||||
@ -485,13 +485,13 @@ image. Commands after the target stage will be skipped.
|
||||
|
||||
```dockerfile
|
||||
FROM debian AS build-env
|
||||
...
|
||||
# ...
|
||||
|
||||
FROM alpine AS production-env
|
||||
...
|
||||
# ...
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build -t mybuildimage --target build-env .
|
||||
```
|
||||
|
||||
@ -516,7 +516,7 @@ The following example builds an image using the current directory (`.`) as build
|
||||
context, and exports the files to a directory named `out` in the current directory.
|
||||
If the directory does not exist, Docker creates the directory automatically:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build -o out .
|
||||
```
|
||||
|
||||
@ -525,13 +525,13 @@ thus uses the default (`local`) exporter. The example below shows the equivalent
|
||||
using the long-hand CSV syntax, specifying both `type` and `dest` (destination
|
||||
path):
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build --output type=local,dest=out .
|
||||
```
|
||||
|
||||
Use the `tar` type to export the files as a `.tar` archive:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build --output type=tar,dest=out.tar .
|
||||
```
|
||||
|
||||
@ -540,8 +540,8 @@ case, `-` is specified as destination, which automatically selects the `tar` typ
|
||||
and writes the output tarball to standard output, which is then redirected to
|
||||
the `out.tar` file:
|
||||
|
||||
```bash
|
||||
docker build -o - . > out.tar
|
||||
```console
|
||||
$ docker build -o - . > out.tar
|
||||
```
|
||||
|
||||
The `--output` option exports all files from the target stage. A common pattern
|
||||
@ -562,7 +562,7 @@ COPY --from=build-stage /go/bin/vndr /
|
||||
When building the Dockerfile with the `-o` option, only the files from the final
|
||||
stage are exported to the `out` directory, in this case, the `vndr` binary:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build -o out .
|
||||
|
||||
[+] Building 2.3s (7/7) FINISHED
|
||||
@ -585,8 +585,9 @@ vndr
|
||||
> **Note**
|
||||
>
|
||||
> This feature requires the BuildKit backend. You can either
|
||||
> [enable BuildKit](../builder.md#buildkit) or use the [buildx](https://github.com/docker/buildx)
|
||||
> plugin which provides more output type options.
|
||||
> [enable BuildKit](https://docs.docker.com/build/buildkit/#getting-started) or
|
||||
> use the [buildx](https://github.com/docker/buildx) plugin which provides more
|
||||
> output type options.
|
||||
|
||||
### Specifying external cache sources
|
||||
|
||||
@ -610,7 +611,7 @@ options) allow pulling layer data for intermediate stages in multi-stage builds.
|
||||
The following example builds an image with inline-cache metadata and pushes it
|
||||
to a registry, then uses the image as a cache source on another machine:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build -t myname/myapp --build-arg BUILDKIT_INLINE_CACHE=1 .
|
||||
$ docker push myname/myapp
|
||||
```
|
||||
@ -618,17 +619,18 @@ $ docker push myname/myapp
|
||||
After pushing the image, the image is used as cache source on another machine.
|
||||
BuildKit automatically pulls the image from the registry if needed.
|
||||
|
||||
```bash
|
||||
# on another machine
|
||||
On another machine:
|
||||
|
||||
```console
|
||||
$ docker build --cache-from myname/myapp .
|
||||
```
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> This feature requires the BuildKit backend. You can either
|
||||
> [enable BuildKit](../builder.md#buildkit) or use the [buildx](https://github.com/docker/buildx)
|
||||
> plugin. The previous builder has limited support for reusing cache from
|
||||
> pre-pulled images.
|
||||
> [enable BuildKit](https://docs.docker.com/build/buildkit/#getting-started) or
|
||||
> use the [buildx](https://github.com/docker/buildx) plugin. The previous
|
||||
> builder has limited support for reusing cache from pre-pulled images.
|
||||
|
||||
### Squash an image's layers (--squash) (experimental)
|
||||
|
||||
@ -666,7 +668,7 @@ The `--squash` option has a number of known limitations:
|
||||
base image is still supported.
|
||||
- When using this option you may see significantly more space used due to
|
||||
storing two copies of the image, one for the build cache with all the cache
|
||||
layers in tact, and one for the squashed version.
|
||||
layers intact, and one for the squashed version.
|
||||
- While squashing layers may produce smaller images, it may have a negative
|
||||
impact on performance, as a single layer takes longer to extract, and
|
||||
downloading a single layer cannot be parallelized.
|
||||
@ -725,7 +727,7 @@ To enable experimental features, you need to start the Docker daemon with
|
||||
|
||||
Then make sure the experimental flag is enabled:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker version -f '{{.Server.Experimental}}'
|
||||
true
|
||||
```
|
||||
@ -745,15 +747,15 @@ RUN rm /remove_me
|
||||
|
||||
An image named `test` is built with `--squash` argument.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker build --squash -t test .
|
||||
|
||||
[...]
|
||||
<...>
|
||||
```
|
||||
|
||||
If everything is right, the history looks like this:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker history test
|
||||
|
||||
IMAGE CREATED CREATED BY SIZE COMMENT
|
||||
|
||||
102
docs/reference/commandline/checkpoint.md
Normal file
102
docs/reference/commandline/checkpoint.md
Normal file
@ -0,0 +1,102 @@
|
||||
---
|
||||
title: docker checkpoint
|
||||
description: "The checkpoint command description and usage"
|
||||
keywords: experimental, checkpoint, restore, criu
|
||||
experimental: true
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
Checkpoint and Restore is an experimental feature that allows you to freeze a running
|
||||
container by checkpointing it, which turns its state into a collection of files
|
||||
on disk. Later, the container can be restored from the point it was frozen.
|
||||
|
||||
This is accomplished using a tool called [CRIU](https://criu.org), which is an
|
||||
external dependency of this feature. A good overview of the history of
|
||||
checkpoint and restore in Docker is available in this
|
||||
[Kubernetes blog post](https://kubernetes.io/blog/2015/07/how-did-quake-demo-from-dockercon-work/).
|
||||
|
||||
### Installing CRIU
|
||||
|
||||
If you use a Debian system, you can add the CRIU PPA and install with `apt-get`
|
||||
[from the criu launchpad](https://launchpad.net/~criu/+archive/ubuntu/ppa).
|
||||
|
||||
Alternatively, you can [build CRIU from source](https://criu.org/Installation).
|
||||
|
||||
You need at least version 2.0 of CRIU to run checkpoint and restore in Docker.
|
||||
|
||||
### Use cases for checkpoint and restore
|
||||
|
||||
This feature is currently focused on single-host use cases for checkpoint and
|
||||
restore. Here are a few:
|
||||
|
||||
- Restarting the host machine without stopping/starting containers
|
||||
- Speeding up the start time of slow start applications
|
||||
- "Rewinding" processes to an earlier point in time
|
||||
- "Forensic debugging" of running processes
|
||||
|
||||
Another primary use case of checkpoint and restore outside of Docker is the live
|
||||
migration of a server from one machine to another. This is possible with the
|
||||
current implementation, but not currently a priority (and so the workflow is
|
||||
not optimized for the task).
|
||||
|
||||
### Using checkpoint and restore
|
||||
|
||||
A new top level command `docker checkpoint` is introduced, with three subcommands:
|
||||
|
||||
- `docker checkpoint create` (creates a new checkpoint)
|
||||
- `docker checkpoint ls` (lists existing checkpoints)
|
||||
- `docker checkpoint rm` (deletes an existing checkpoint)
|
||||
|
||||
Additionally, a `--checkpoint` flag is added to the `docker container start` command.
|
||||
|
||||
The options for `docker checkpoint create`:
|
||||
|
||||
```console
|
||||
Usage: docker checkpoint create [OPTIONS] CONTAINER CHECKPOINT
|
||||
|
||||
Create a checkpoint from a running container
|
||||
|
||||
--leave-running=false Leave the container running after checkpoint
|
||||
--checkpoint-dir Use a custom checkpoint storage directory
|
||||
```
|
||||
|
||||
And to restore a container:
|
||||
|
||||
```console
|
||||
Usage: docker start --checkpoint CHECKPOINT_ID [OTHER OPTIONS] CONTAINER
|
||||
```
|
||||
|
||||
Example of using checkpoint and restore on a container:
|
||||
|
||||
```console
|
||||
$ docker run --security-opt=seccomp:unconfined --name cr -d busybox /bin/sh -c 'i=0; while true; do echo $i; i=$(expr $i + 1); sleep 1; done'
|
||||
abc0123
|
||||
|
||||
$ docker checkpoint create cr checkpoint1
|
||||
|
||||
# <later>
|
||||
$ docker start --checkpoint checkpoint1 cr
|
||||
abc0123
|
||||
```
|
||||
|
||||
This process just logs an incrementing counter to stdout. If you run `docker logs`
|
||||
in between running/checkpoint/restoring you should see that the counter
|
||||
increases while the process is running, stops while it's checkpointed, and
|
||||
resumes from the point it left off once you restore.
|
||||
|
||||
### Known limitations
|
||||
|
||||
seccomp is only supported by CRIU in very up to date kernels.
|
||||
|
||||
External terminal (i.e. `docker run -t ..`) is not supported at the moment.
|
||||
If you try to create a checkpoint for a container with an external terminal,
|
||||
it would fail:
|
||||
|
||||
```console
|
||||
$ docker checkpoint create cr checkpoint1
|
||||
Error response from daemon: Cannot checkpoint container c1: rpc error: code = 2 desc = exit status 1: "criu failed: type NOTIFY errno 0\nlog file: /var/lib/docker/containers/eb62ebdbf237ce1a8736d2ae3c7d88601fc0a50235b0ba767b559a1f3c5a600b/checkpoints/checkpoint1/criu.work/dump.log\n"
|
||||
|
||||
$ cat /var/lib/docker/containers/eb62ebdbf237ce1a8736d2ae3c7d88601fc0a50235b0ba767b559a1f3c5a600b/checkpoints/checkpoint1/criu.work/dump.log
|
||||
Error (mount.c:740): mnt: 126:./dev/console doesn't have a proper root mount
|
||||
```
|
||||
@ -3,7 +3,7 @@ title: "Use the Docker command line"
|
||||
description: "Docker's CLI command description and usage"
|
||||
keywords: "Docker, Docker documentation, CLI, command line, config.json, CLI configuration file"
|
||||
redirect_from:
|
||||
- /go/experimental/
|
||||
- /reference/commandline/cli/
|
||||
- /engine/reference/commandline/engine/
|
||||
- /engine/reference/commandline/engine_activate/
|
||||
- /engine/reference/commandline/engine_check/
|
||||
@ -24,7 +24,7 @@ redirect_from:
|
||||
To list available commands, either run `docker` with no parameters
|
||||
or execute `docker help`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker
|
||||
Usage: docker [OPTIONS] COMMAND [ARG...]
|
||||
docker [ --help | -v | --version ]
|
||||
@ -78,6 +78,7 @@ line:
|
||||
| `DOCKER_HOST` | Daemon socket to connect to. |
|
||||
| `DOCKER_STACK_ORCHESTRATOR` | Configure the default orchestrator to use when using `docker stack` management commands. |
|
||||
| `DOCKER_TLS_VERIFY` | When set Docker uses TLS and verifies the remote. This variable is used both by the `docker` CLI and the [`dockerd` daemon](dockerd.md) |
|
||||
| `BUILDKIT_PROGRESS` | Set type of progress output (`auto`, `plain`, `tty`) when [building](build.md) with [BuildKit backend](https://docs.docker.com/build/buildkit/). Use plain to show container output (default `auto`). |
|
||||
|
||||
Because Docker is developed using Go, you can also use any environment
|
||||
variables used by the Go runtime. In particular, you may find these useful:
|
||||
@ -87,7 +88,7 @@ variables used by the Go runtime. In particular, you may find these useful:
|
||||
* `NO_PROXY`
|
||||
|
||||
These Go environment variables are case-insensitive. See the
|
||||
[Go specification](http://golang.org/pkg/net/http/) for details on these
|
||||
[Go specification](https://golang.org/pkg/net/http/) for details on these
|
||||
variables.
|
||||
|
||||
## Configuration files
|
||||
@ -312,6 +313,9 @@ Experimental features provide early access to future product functionality.
|
||||
These features are intended for testing and feedback, and they may change
|
||||
between releases without warning or can be removed from a future release.
|
||||
|
||||
Starting with Docker 20.10, experimental CLI features are enabled by default,
|
||||
and require no configuration to enable them.
|
||||
|
||||
### Notary
|
||||
|
||||
If using your own notary server and a self-signed certificate or an internal
|
||||
|
||||
@ -43,7 +43,7 @@ created. Supported `Dockerfile` instructions:
|
||||
|
||||
### Commit a container
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
@ -62,7 +62,7 @@ svendowideit/testimage version3 f5283438590d 16 sec
|
||||
|
||||
### Commit a container with new configurations
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
@ -84,7 +84,7 @@ $ docker inspect -f "{{ .Config.Env }}" f5283438590d
|
||||
|
||||
### Commit a container with new `CMD` and `EXPOSE` instructions
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
|
||||
@ -33,7 +33,7 @@ For detailed information about using configs, refer to [store configuration data
|
||||
|
||||
### Create a config
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ printf <config> | docker config create my_config -
|
||||
|
||||
onakdyv307se2tl7nl20anokv
|
||||
@ -46,7 +46,7 @@ onakdyv307se2tl7nl20anokv my_config 6 seconds ago 6 seconds ag
|
||||
|
||||
### Create a config with a file
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config create my_config ./config.json
|
||||
|
||||
dg426haahpi5ezmkkj5kyl3sn
|
||||
@ -59,7 +59,7 @@ dg426haahpi5ezmkkj5kyl3sn my_config 7 seconds ago 7 seconds ag
|
||||
|
||||
### Create a config with labels
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config create \
|
||||
--label env=dev \
|
||||
--label rev=20170324 \
|
||||
@ -68,7 +68,7 @@ $ docker config create \
|
||||
eo7jnzguqgtpdah3cm5srfb97
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config inspect my_config
|
||||
|
||||
[
|
||||
|
||||
@ -23,7 +23,7 @@ Inspects the specified config.
|
||||
By default, this renders all results in a JSON array. If a format is specified,
|
||||
the given template will be executed for each result.
|
||||
|
||||
Go's [text/template](http://golang.org/pkg/text/template/) package
|
||||
Go's [text/template](https://golang.org/pkg/text/template/) package
|
||||
describes all the details of the format.
|
||||
|
||||
For detailed information about using configs, refer to [store configuration data using Docker Configs](https://docs.docker.com/engine/swarm/configs/).
|
||||
@ -43,14 +43,14 @@ You can inspect a config, either by its *name*, or *ID*
|
||||
|
||||
For example, given the following config:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config ls
|
||||
|
||||
ID NAME CREATED UPDATED
|
||||
eo7jnzguqgtpdah3cm5srfb97 my_config 3 minutes ago 3 minutes ago
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config inspect config.json
|
||||
```
|
||||
|
||||
@ -83,7 +83,7 @@ You can use the --format option to obtain specific information about a
|
||||
config. The following example command outputs the creation time of the
|
||||
config.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config inspect --format='{{.CreatedAt}}' eo7jnzguqgtpdah3cm5srfb97
|
||||
|
||||
2017-03-24 08:15:09.735271783 +0000 UTC
|
||||
|
||||
@ -36,7 +36,7 @@ For detailed information about using configs, refer to [store configuration data
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config ls
|
||||
|
||||
ID NAME CREATED UPDATED
|
||||
@ -60,7 +60,7 @@ The currently supported filters are:
|
||||
|
||||
The `id` filter matches all or prefix of a config's id.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config ls -f "id=6697bflskwj1998km1gnnjr38"
|
||||
|
||||
ID NAME CREATED UPDATED
|
||||
@ -75,7 +75,7 @@ a `label` and a value.
|
||||
The following filter matches all configs with a `project` label regardless of
|
||||
its value:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config ls --filter label=project
|
||||
|
||||
ID NAME CREATED UPDATED
|
||||
@ -85,7 +85,7 @@ mem02h8n73mybpgqjf0kfi1n0 test_config About an hour ago Abou
|
||||
The following filter matches only services with the `project` label with the
|
||||
`project-a` value.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker service ls --filter label=project=test
|
||||
|
||||
ID NAME CREATED UPDATED
|
||||
@ -98,7 +98,7 @@ The `name` filter matches on all or prefix of a config's name.
|
||||
|
||||
The following filter matches config with a name containing a prefix of `test`.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config ls --filter name=test_config
|
||||
|
||||
ID NAME CREATED UPDATED
|
||||
@ -113,7 +113,7 @@ using a Go template.
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
| Placeholder | Description |
|
||||
| ------------ | ------------------------------------------------------------------------------------ |
|
||||
|--------------|--------------------------------------------------------------------------------------|
|
||||
| `.ID` | Config ID |
|
||||
| `.Name` | Config name |
|
||||
| `.CreatedAt` | Time when the config was created |
|
||||
@ -128,7 +128,7 @@ output the data exactly as the template declares or, when using the
|
||||
The following example uses a template without headers and outputs the
|
||||
`ID` and `Name` entries separated by a colon (`:`) for all images:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config ls --format "{{.ID}}: {{.Name}}"
|
||||
|
||||
77af4d6b9913: config-1
|
||||
@ -139,7 +139,7 @@ b6fa739cedf5: config-2
|
||||
To list all configs with their name and created date in a table format you
|
||||
can use:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config ls --format "table {{.ID}}\t{{.Name}}\t{{.CreatedAt}}"
|
||||
|
||||
ID NAME CREATED
|
||||
|
||||
@ -35,7 +35,7 @@ For detailed information about using configs, refer to [store configuration data
|
||||
|
||||
This example removes a config:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker config rm my_config
|
||||
sapth4csdo5b6wz2p5uimh5xg
|
||||
```
|
||||
|
||||
@ -26,7 +26,7 @@ Removes all stopped containers.
|
||||
|
||||
### Prune containers
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker container prune
|
||||
WARNING! This will remove all stopped containers.
|
||||
Are you sure you want to continue? [y/N] y
|
||||
@ -66,7 +66,7 @@ containers without the specified labels.
|
||||
|
||||
The following removes containers created more than 5 minutes ago:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED AT STATUS
|
||||
@ -88,7 +88,7 @@ CONTAINER ID IMAGE COMMAND CREATED AT
|
||||
|
||||
The following removes containers created before `2017-01-04T13:10:00`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED AT STATUS
|
||||
|
||||
45
docs/reference/commandline/context.md
Normal file
45
docs/reference/commandline/context.md
Normal file
@ -0,0 +1,45 @@
|
||||
---
|
||||
title: "context"
|
||||
description: "The context command description and usage"
|
||||
keywords: "context"
|
||||
---
|
||||
|
||||
# config
|
||||
|
||||
```markdown
|
||||
Manage contexts
|
||||
|
||||
Usage:
|
||||
docker context [command]
|
||||
|
||||
Available Commands:
|
||||
create Create new context
|
||||
export Export a context to a tar or kubeconfig file
|
||||
import Import a context from a tar or zip file
|
||||
inspect Display detailed information on one or more contexts
|
||||
list List available contexts
|
||||
rm Remove one or more contexts
|
||||
show Print the current context
|
||||
update Update a context
|
||||
use Set the default context
|
||||
|
||||
Flags:
|
||||
-h, --help Help for context
|
||||
|
||||
Use "docker context [command] --help" for more information about a command.
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Manage contexts.
|
||||
|
||||
## Related commands
|
||||
|
||||
* [context create](context_create.md)
|
||||
* [context export](context_export.md)
|
||||
* [context import](context_import.md)
|
||||
* [context inspect](context_inspect.md)
|
||||
* [context list](context_ls.md)
|
||||
* [context rm](context_rm.md)
|
||||
* [context update](context_update.md)
|
||||
* [context use](context_use.md)
|
||||
@ -62,7 +62,7 @@ kubernetes options. The example below creates the context `my-context`
|
||||
with a docker endpoint of `/var/run/docker.sock` and a kubernetes configuration
|
||||
sourced from the file `/home/me/my-kube-config`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker context create \
|
||||
--docker host=unix:///var/run/docker.sock \
|
||||
--kubernetes config-file=/home/me/my-kube-config \
|
||||
@ -75,19 +75,19 @@ Use the `--from=<context-name>` option to create a new context from
|
||||
an existing context. The example below creates a new context named `my-context`
|
||||
from the existing context `existing-context`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker context create --from existing-context my-context
|
||||
```
|
||||
|
||||
If the `--from` option is not set, the `context` is created from the current context:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker context create my-context
|
||||
```
|
||||
|
||||
This can be used to create a context out of an existing `DOCKER_HOST` based script:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ source my-setup-script.sh
|
||||
$ docker context create my-context
|
||||
```
|
||||
@ -98,7 +98,7 @@ new context named `my-context` using the docker endpoint configuration from
|
||||
the existing context `existing-context` and a kubernetes configuration sourced
|
||||
from the file `/home/me/my-kube-config`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker context create \
|
||||
--docker from=existing-context \
|
||||
--kubernetes config-file=/home/me/my-kube-config \
|
||||
@ -110,7 +110,7 @@ To source only the `kubernetes` configuration from an existing context use the
|
||||
context named `my-context` using the kuberentes configuration from the existing
|
||||
context `existing-context` and a docker endpoint of `/var/run/docker.sock`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker context create \
|
||||
--docker host=unix:///var/run/docker.sock \
|
||||
--kubernetes from=existing-context \
|
||||
|
||||
@ -23,7 +23,7 @@ Inspects one or more contexts.
|
||||
|
||||
### Inspect a context by name
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker context inspect "local+aks"
|
||||
|
||||
[
|
||||
|
||||
@ -25,7 +25,9 @@ Options:
|
||||
Use `docker context ls` to print all contexts. The currently active context is
|
||||
indicated with an `*`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker context ls
|
||||
|
||||
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
|
||||
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
|
||||
production tcp:///prod.corp.example.com:2376
|
||||
|
||||
@ -54,7 +54,7 @@ See [context create](context_create.md).
|
||||
|
||||
### Update an existing context
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker context update \
|
||||
--description "some description" \
|
||||
--docker "host=tcp://myserver:2376,ca=~/ca-file,cert=~/cert-file,key=~/key-file" \
|
||||
|
||||
@ -13,6 +13,7 @@ Set the current docker context
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Set the default context to use, when `DOCKER_HOST`, `DOCKER_CONTEXT` environment
|
||||
variables and `--host`, `--context` global options are not set.
|
||||
To disable usage of contexts, you can use the special `default` context.
|
||||
|
||||
@ -89,17 +89,39 @@ you must be explicit with a relative or absolute path, for example:
|
||||
|
||||
`/path/to/file:name.txt` or `./file:name.txt`
|
||||
|
||||
## Examples
|
||||
|
||||
Copy a local file into container
|
||||
|
||||
```console
|
||||
$ docker cp ./some_file CONTAINER:/work
|
||||
```
|
||||
|
||||
Copy files from container to local path
|
||||
|
||||
```console
|
||||
$ docker cp CONTAINER:/var/logs/ /tmp/app_logs
|
||||
```
|
||||
|
||||
Copy a file from container to stdout. Please note `cp` command produces a tar stream
|
||||
|
||||
```console
|
||||
$ docker cp CONTAINER:/var/logs/app.log - | tar x -O | grep "ERROR"
|
||||
```
|
||||
|
||||
### Corner cases
|
||||
|
||||
It is not possible to copy certain system files such as resources under
|
||||
`/proc`, `/sys`, `/dev`, [tmpfs](run.md#mount-tmpfs---tmpfs), and mounts created by
|
||||
the user in the container. However, you can still copy such files by manually
|
||||
running `tar` in `docker exec`. Both of the following examples do the same thing
|
||||
in different ways (consider `SRC_PATH` and `DEST_PATH` are directories):
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker exec CONTAINER tar Ccf $(dirname SRC_PATH) - $(basename SRC_PATH) | tar Cxf DEST_PATH -
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ tar Ccf $(dirname SRC_PATH) - $(basename SRC_PATH) | docker exec -i CONTAINER tar Cxf DEST_PATH -
|
||||
```
|
||||
|
||||
|
||||
@ -98,6 +98,7 @@ Options:
|
||||
--privileged Give extended privileges to this container
|
||||
-p, --publish value Publish a container's port(s) to the host (default [])
|
||||
-P, --publish-all Publish all exposed ports to random ports
|
||||
--pull string Pull image before creating ("always"|"missing"|"never") (default "missing")
|
||||
--read-only Mount the container's root filesystem as read only
|
||||
--restart string Restart policy to apply when a container exits (default "no")
|
||||
Possible values are: no, on-failure[:max-retry], always, unless-stopped
|
||||
@ -109,7 +110,7 @@ Options:
|
||||
Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes),
|
||||
or `g` (gigabytes). If you omit the unit, the system uses bytes.
|
||||
--stop-signal string Signal to stop a container (default "SIGTERM")
|
||||
--stop-timeout=10 Timeout (in seconds) to stop a container
|
||||
--stop-timeout int Timeout (in seconds) to stop a container
|
||||
--storage-opt value Storage driver options for the container (default [])
|
||||
--sysctl value Sysctl options (default map[])
|
||||
--tmpfs value Mount a tmpfs directory (default [])
|
||||
@ -131,41 +132,58 @@ Options:
|
||||
--volumes-from value Mount volumes from the specified container(s) (default [])
|
||||
-w, --workdir string Working directory inside the container
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `docker create` command creates a writeable container layer over the
|
||||
specified image and prepares it for running the specified command. The
|
||||
The `docker container create` (or shorthand: `docker create`) command creates a
|
||||
new container from the specified image, without starting it.
|
||||
|
||||
When creating a container, the docker daemon creates a writeable container layer
|
||||
over the specified image and prepares it for running the specified command. The
|
||||
container ID is then printed to `STDOUT`. This is similar to `docker run -d`
|
||||
except the container is never started. You can then use the
|
||||
`docker start <container_id>` command to start the container at any point.
|
||||
except the container is never started. You can then use the `docker container start`
|
||||
(or shorthand: `docker start`) command to start the container at any point.
|
||||
|
||||
This is useful when you want to set up a container configuration ahead of time
|
||||
so that it is ready to start when you need it. The initial status of the
|
||||
new container is `created`.
|
||||
|
||||
Please see the [run command](run.md) section and the [Docker run reference](../run.md) for more details.
|
||||
The `docker create` command shares most of its options with the `docker run`
|
||||
command (which performs a `docker create` before starting it). Refer to the
|
||||
[`docker run` command](run.md) section and the [Docker run reference](../run.md)
|
||||
for details on the available flags and options.
|
||||
|
||||
## Examples
|
||||
|
||||
### Create and start a container
|
||||
|
||||
```bash
|
||||
$ docker create -t -i fedora bash
|
||||
The following example creates an interactive container with a pseudo-TTY attached,
|
||||
then starts the container and attaches to it:
|
||||
|
||||
```console
|
||||
$ docker container create -i -t --name mycontainer alpine
|
||||
6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752
|
||||
|
||||
$ docker start -a -i 6d8af538ec5
|
||||
$ docker container start --attach -i mycontainer
|
||||
/ # echo hello world
|
||||
hello world
|
||||
```
|
||||
|
||||
bash-4.2#
|
||||
The above is the equivalent of a `docker run`:
|
||||
|
||||
```console
|
||||
$ docker run -it --name mycontainer2 alpine
|
||||
/ # echo hello world
|
||||
hello world
|
||||
```
|
||||
|
||||
### Initialize volumes
|
||||
|
||||
As of v1.4.0 container volumes are initialized during the `docker create` phase
|
||||
Container volumes are initialized during the `docker create` phase
|
||||
(i.e., `docker run` too). For example, this allows you to `create` the `data`
|
||||
volume container, and then use it from another container:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker create -v /data --name data ubuntu
|
||||
|
||||
240633dfbb98128fa77473d3d9018f6123b99c454b3251427ae190a7d951ad57
|
||||
@ -180,7 +198,7 @@ drwxr-xr-x 48 root root 4096 Dec 5 04:11 ..
|
||||
Similarly, `create` a host directory bind mounted volume container, which can
|
||||
then be used from the subsequent container:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker create -v /home/docker:/docker --name docker ubuntu
|
||||
|
||||
9aa88c08f319cd1e4515c3c46b0de7cc9aa75e878357b1e96f91e2c773029f03
|
||||
@ -198,59 +216,3 @@ drwxr-sr-x 3 1000 staff 60 Dec 1 03:28 .local
|
||||
drwx--S--- 2 1000 staff 460 Dec 5 00:51 .ssh
|
||||
drwxr-xr-x 32 1000 staff 1140 Dec 5 04:01 docker
|
||||
```
|
||||
|
||||
|
||||
Set storage driver options per container.
|
||||
|
||||
```bash
|
||||
$ docker create -it --storage-opt size=120G fedora /bin/bash
|
||||
```
|
||||
|
||||
This (size) will allow to set the container rootfs size to 120G at creation time.
|
||||
This option is only available for the `devicemapper`, `btrfs`, `overlay2`,
|
||||
`windowsfilter` and `zfs` graph drivers.
|
||||
For the `devicemapper`, `btrfs`, `windowsfilter` and `zfs` graph drivers,
|
||||
user cannot pass a size less than the Default BaseFS Size.
|
||||
For the `overlay2` storage driver, the size option is only available if the
|
||||
backing fs is `xfs` and mounted with the `pquota` mount option.
|
||||
Under these conditions, user can pass any size less than the backing fs size.
|
||||
|
||||
### Specify isolation technology for container (--isolation)
|
||||
|
||||
This option is useful in situations where you are running Docker containers on
|
||||
Windows. The `--isolation=<value>` option sets a container's isolation
|
||||
technology. On Linux, the only supported is the `default` option which uses
|
||||
Linux namespaces. On Microsoft Windows, you can specify these values:
|
||||
|
||||
|
||||
| Value | Description |
|
||||
|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `default` | Use the value specified by the Docker daemon's `--exec-opt` . If the `daemon` does not specify an isolation technology, Microsoft Windows uses `process` as its default value if the
|
||||
daemon is running on Windows server, or `hyperv` if running on Windows client. |
|
||||
| `process` | Namespace isolation only. |
|
||||
| `hyperv` | Hyper-V hypervisor partition-based isolation. |
|
||||
|
||||
Specifying the `--isolation` flag without a value is the same as setting `--isolation="default"`.
|
||||
|
||||
### Dealing with dynamically created devices (--device-cgroup-rule)
|
||||
|
||||
Devices available to a container are assigned at creation time. The
|
||||
assigned devices will both be added to the cgroup.allow file and
|
||||
created into the container once it is run. This poses a problem when
|
||||
a new device needs to be added to running container.
|
||||
|
||||
One of the solution is to add a more permissive rule to a container
|
||||
allowing it access to a wider range of devices. For example, supposing
|
||||
our container needs access to a character device with major `42` and
|
||||
any number of minor number (added as new devices appear), the
|
||||
following rule would be added:
|
||||
|
||||
```
|
||||
docker create --device-cgroup-rule='c 42:* rmw' -name my-container my-image
|
||||
```
|
||||
|
||||
Then, a user could ask `udev` to execute a script that would `docker exec my-container mknod newDevX c 42 <minor>`
|
||||
the required device when it is added.
|
||||
|
||||
NOTE: initially present devices still need to be explicitly added to
|
||||
the create/run command
|
||||
|
||||
@ -33,7 +33,7 @@ You can use the full or shortened container ID or the container name set using
|
||||
|
||||
Inspect the changes to an `nginx` container:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker diff 1fdfd1f54c1b
|
||||
|
||||
C /dev
|
||||
|
||||
@ -115,8 +115,8 @@ Options with [] may be specified multiple times.
|
||||
uses different binaries for the daemon and client. To run the daemon you
|
||||
type `dockerd`.
|
||||
|
||||
To run the daemon with debug output, use `dockerd -D` or add `"debug": true` to
|
||||
the `daemon.json` file.
|
||||
To run the daemon with debug output, use `dockerd --debug` or add `"debug": true`
|
||||
to [the `daemon.json` file](#daemon-configuration-file).
|
||||
|
||||
> **Enabling experimental features**
|
||||
>
|
||||
@ -164,7 +164,7 @@ communication with the daemon.
|
||||
> supported anymore for security reasons.
|
||||
|
||||
On Systemd based systems, you can communicate with the daemon via
|
||||
[Systemd socket activation](http://0pointer.de/blog/projects/socket-activation.html),
|
||||
[Systemd socket activation](https://0pointer.de/blog/projects/socket-activation.html),
|
||||
use `dockerd -H fd://`. Using `fd://` will work perfectly for most setups but
|
||||
you can also specify individual sockets: `dockerd -H fd://3`. If the
|
||||
specified socket activated files aren't found, then Docker will exit. You can
|
||||
@ -174,20 +174,21 @@ find examples of using Systemd socket activation with Docker and Systemd in the
|
||||
You can configure the Docker daemon to listen to multiple sockets at the same
|
||||
time using multiple `-H` options:
|
||||
|
||||
```bash
|
||||
# listen using the default unix socket, and on 2 specific IP addresses on this host.
|
||||
The example below runs the daemon listenin on the default unix socket, and
|
||||
on 2 specific IP addresses on this host:
|
||||
|
||||
```console
|
||||
$ sudo dockerd -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2
|
||||
```
|
||||
|
||||
The Docker client will honor the `DOCKER_HOST` environment variable to set the
|
||||
`-H` flag for the client. Use **one** of the following commands:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker -H tcp://0.0.0.0:2375 ps
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ export DOCKER_HOST="tcp://0.0.0.0:2375"
|
||||
|
||||
$ docker ps
|
||||
@ -197,7 +198,7 @@ Setting the `DOCKER_TLS_VERIFY` environment variable to any value other than
|
||||
the empty string is equivalent to setting the `--tlsverify` flag. The following
|
||||
are equivalent:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker --tlsverify ps
|
||||
# or
|
||||
$ export DOCKER_TLS_VERIFY=1
|
||||
@ -210,7 +211,7 @@ precedence over `HTTP_PROXY`.
|
||||
|
||||
The Docker client supports connecting to a remote daemon via SSH:
|
||||
|
||||
```
|
||||
```console
|
||||
$ docker -H ssh://me@example.com:22 ps
|
||||
$ docker -H ssh://me@example.com ps
|
||||
$ docker -H ssh://example.com ps
|
||||
@ -267,22 +268,21 @@ when no `-H` was passed in.
|
||||
|
||||
Run Docker in daemon mode:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo <path to>/dockerd -H 0.0.0.0:5555 &
|
||||
```
|
||||
|
||||
Download an `ubuntu` image:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker -H :5555 pull ubuntu
|
||||
```
|
||||
|
||||
You can use multiple `-H`, for example, if you want to listen on both
|
||||
TCP and a Unix socket
|
||||
|
||||
```bash
|
||||
# Run docker in daemon mode
|
||||
$ sudo <path to>/dockerd -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock &
|
||||
```console
|
||||
$ sudo dockerd -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock &
|
||||
# Download an ubuntu image, use default Unix socket
|
||||
$ docker pull ubuntu
|
||||
# OR use the TCP port
|
||||
@ -307,12 +307,12 @@ devices, one for data and one for metadata. By default, these block devices
|
||||
are created automatically by using loopback mounts of automatically created
|
||||
sparse files. Refer to [Devicemapper options](#devicemapper-options) below
|
||||
for a way how to customize this setup.
|
||||
[~jpetazzo/Resizing Docker containers with the Device Mapper plugin](http://jpetazzo.github.io/2014/01/29/docker-device-mapper-resize/)
|
||||
[~jpetazzo/Resizing Docker containers with the Device Mapper plugin](https://jpetazzo.github.io/2014/01/29/docker-device-mapper-resize/)
|
||||
article explains how to tune your existing setup without the use of options.
|
||||
|
||||
The `btrfs` driver is very fast for `docker build` - but like `devicemapper`
|
||||
does not share executable memory between devices. Use
|
||||
`dockerd -s btrfs -g /mnt/btrfs_partition`.
|
||||
`dockerd --storage-driver btrfs --data-root /mnt/btrfs_partition`.
|
||||
|
||||
The `zfs` driver is probably not as fast as `btrfs` but has a longer track record
|
||||
on stability. Thanks to `Single Copy ARC` shared blocks between clones will be
|
||||
@ -395,7 +395,7 @@ not use loopback in production. Ensure your Engine daemon has a
|
||||
|
||||
###### Example:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.thinpooldev=/dev/mapper/thin-pool
|
||||
```
|
||||
|
||||
@ -406,7 +406,7 @@ device for you.
|
||||
|
||||
###### Example:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.directlvm_device=/dev/xvdf
|
||||
```
|
||||
|
||||
@ -416,7 +416,7 @@ Sets the percentage of passed in block device to use for storage.
|
||||
|
||||
###### Example:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.thinp_percent=95
|
||||
```
|
||||
|
||||
@ -426,7 +426,7 @@ Sets the percentage of the passed in block device to use for metadata storage.
|
||||
|
||||
###### Example:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.thinp_metapercent=1
|
||||
```
|
||||
|
||||
@ -437,7 +437,7 @@ autoextend the available space [100 = disabled]
|
||||
|
||||
###### Example:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.thinp_autoextend_threshold=80
|
||||
```
|
||||
|
||||
@ -448,7 +448,7 @@ attempts to autoextend the available space [100 = disabled]
|
||||
|
||||
###### Example:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.thinp_autoextend_percent=20
|
||||
```
|
||||
|
||||
@ -467,7 +467,7 @@ new base device size.
|
||||
|
||||
###### Examples
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.basesize=50G
|
||||
```
|
||||
|
||||
@ -479,7 +479,7 @@ This value affects the system-wide "base" empty filesystem
|
||||
that may already be initialized and inherited by pulled images. Typically,
|
||||
a change to this value requires additional steps to take effect:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo service docker stop
|
||||
|
||||
$ sudo rm -rf /var/lib/docker
|
||||
@ -502,7 +502,7 @@ much space.
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.loopdatasize=200G
|
||||
```
|
||||
|
||||
@ -520,7 +520,7 @@ this much space.
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.loopmetadatasize=4G
|
||||
```
|
||||
|
||||
@ -531,7 +531,7 @@ options are "ext4" and "xfs". The default is "xfs"
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.fs=ext4
|
||||
```
|
||||
|
||||
@ -541,7 +541,7 @@ Specifies extra mkfs arguments to be used when creating the base device.
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt "dm.mkfsarg=-O ^has_journal"
|
||||
```
|
||||
|
||||
@ -551,7 +551,7 @@ Specifies extra mount options used when mounting the thin devices.
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.mountopt=nodiscard
|
||||
```
|
||||
|
||||
@ -567,7 +567,7 @@ device.
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd \
|
||||
--storage-opt dm.datadev=/dev/sdb1 \
|
||||
--storage-opt dm.metadatadev=/dev/sdc1
|
||||
@ -585,13 +585,13 @@ data, or even better on an SSD.
|
||||
If setting up a new metadata pool it is required to be valid. This can be
|
||||
achieved by zeroing the first 4k to indicate empty metadata, like this:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ dd if=/dev/zero of=$metadata_dev bs=4096 count=1
|
||||
```
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd \
|
||||
--storage-opt dm.datadev=/dev/sdb1 \
|
||||
--storage-opt dm.metadatadev=/dev/sdc1
|
||||
@ -604,7 +604,7 @@ blocksize is 64K.
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.blocksize=512K
|
||||
```
|
||||
|
||||
@ -620,7 +620,7 @@ returned to the system for other use when containers are removed.
|
||||
|
||||
###### Examples
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.blkdiscard=false
|
||||
```
|
||||
|
||||
@ -632,11 +632,11 @@ Overrides the `udev` synchronization checks between `devicemapper` and `udev`.
|
||||
To view the `udev` sync support of a Docker daemon that is using the
|
||||
`devicemapper` driver, run:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker info
|
||||
[...]
|
||||
<...>
|
||||
Udev Sync Supported: true
|
||||
[...]
|
||||
<...>
|
||||
```
|
||||
|
||||
When `udev` sync support is `true`, then `devicemapper` and udev can
|
||||
@ -650,7 +650,7 @@ results in errors and failures. (For information on these failures, see
|
||||
To allow the `docker` daemon to start, regardless of `udev` sync not being
|
||||
supported, set `dm.override_udev_sync_check` to true:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.override_udev_sync_check=true
|
||||
```
|
||||
|
||||
@ -683,7 +683,7 @@ loop trying to remove a busy device.
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.use_deferred_removal=true
|
||||
```
|
||||
|
||||
@ -701,7 +701,7 @@ Error deleting container: Error response from daemon: Cannot destroy container
|
||||
To avoid this failure, enable both deferred device deletion and deferred
|
||||
device removal on the daemon.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd \
|
||||
--storage-opt dm.use_deferred_deletion=true \
|
||||
--storage-opt dm.use_deferred_removal=true
|
||||
@ -741,7 +741,7 @@ the issue.
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.min_free_space=10%
|
||||
```
|
||||
|
||||
@ -757,7 +757,7 @@ ENOSPC and will shutdown filesystem.
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --storage-opt dm.xfs_nospace_max_retries=0
|
||||
```
|
||||
|
||||
@ -773,7 +773,7 @@ time of writing, the following is the list of `libdm` log levels as well as
|
||||
their corresponding levels when output by `dockerd`.
|
||||
|
||||
| `libdm` Level | Value | `--log-level` |
|
||||
| ------------- | -----:| ------------- |
|
||||
|---------------|------:|---------------|
|
||||
| `_LOG_FATAL` | 2 | error |
|
||||
| `_LOG_ERR` | 3 | error |
|
||||
| `_LOG_WARN` | 4 | warn |
|
||||
@ -783,7 +783,7 @@ their corresponding levels when output by `dockerd`.
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd \
|
||||
--log-level debug \
|
||||
--storage-opt dm.libdm_log_level=7
|
||||
@ -799,7 +799,7 @@ By default docker will pick up the zfs filesystem where docker graph
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd -s zfs --storage-opt zfs.fsname=zroot/docker
|
||||
```
|
||||
|
||||
@ -814,30 +814,21 @@ a container with **--storage-opt size** option, docker should ensure the
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd -s btrfs --storage-opt btrfs.min_space=10G
|
||||
```
|
||||
|
||||
#### Overlay2 options
|
||||
|
||||
##### `overlay2.override_kernel_check`
|
||||
|
||||
Overrides the Linux kernel version check allowing overlay2. Support for
|
||||
specifying multiple lower directories needed by overlay2 was added to the
|
||||
Linux kernel in 4.0.0. However, some older kernel versions may be patched
|
||||
to add multiple lower directory support for OverlayFS. This option should
|
||||
only be used after verifying this support exists in the kernel. Applying
|
||||
this option on a kernel without this support will cause failures on mount.
|
||||
|
||||
##### `overlay2.size`
|
||||
|
||||
Sets the default max size of the container. It is supported only when the
|
||||
backing fs is `xfs` and mounted with `pquota` mount option. Under these
|
||||
conditions the user can pass any size less then the backing fs size.
|
||||
conditions the user can pass any size less than the backing fs size.
|
||||
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd -s overlay2 --storage-opt overlay2.size=1G
|
||||
```
|
||||
|
||||
@ -959,7 +950,7 @@ By default, the Docker daemon automatically starts `containerd`. If you want to
|
||||
control `containerd` startup, manually start `containerd` and pass the path to
|
||||
the `containerd` socket using the `--containerd` flag. For example:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --containerd /var/run/dev/docker-containerd.sock
|
||||
```
|
||||
|
||||
@ -987,7 +978,7 @@ The following is an example adding 2 runtimes via the configuration:
|
||||
|
||||
This is the same example via the command line:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-runc-replacement
|
||||
```
|
||||
|
||||
@ -1009,7 +1000,7 @@ is used on cgroup v2 hosts with systemd available.
|
||||
|
||||
This example sets the `cgroupdriver` to `systemd`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --exec-opt native.cgroupdriver=systemd
|
||||
```
|
||||
|
||||
@ -1030,13 +1021,13 @@ value is specified on daemon start, on Windows client, the default is
|
||||
|
||||
To set the DNS server for all Docker containers, use:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --dns 8.8.8.8
|
||||
```
|
||||
|
||||
To set the DNS search domain for all Docker containers, use:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --dns-search example.com
|
||||
```
|
||||
|
||||
@ -1162,7 +1153,7 @@ TLS. To configure the client TLS settings used by the daemon can be configured
|
||||
using the `--cluster-store-opt` flag, specifying the paths to PEM encoded
|
||||
files. For example:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd \
|
||||
--cluster-advertise 192.168.1.2:2376 \
|
||||
--cluster-store etcd://192.168.1.2:2379 \
|
||||
@ -1189,7 +1180,7 @@ organization can purchase or build themselves. You can install one or more
|
||||
authorization plugins when you start the Docker `daemon` using the
|
||||
`--authorization-plugin=PLUGIN_ID` option.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ sudo dockerd --authorization-plugin=plugin1 --authorization-plugin=plugin2,...
|
||||
```
|
||||
|
||||
@ -1210,7 +1201,7 @@ For information about how to create an authorization plugin, refer to the
|
||||
### Daemon user namespace options
|
||||
|
||||
The Linux kernel
|
||||
[user namespace support](http://man7.org/linux/man-pages/man7/user_namespaces.7.html)
|
||||
[user namespace support](https://man7.org/linux/man-pages/man7/user_namespaces.7.html)
|
||||
provides additional security by enabling a process, and therefore a container,
|
||||
to have a unique range of user and group IDs which are outside the traditional
|
||||
user and group range utilized by the host system. Potentially the most important
|
||||
@ -1233,14 +1224,14 @@ for `/var/lib/docker/tmp`. The `DOCKER_TMPDIR` and the data directory can be
|
||||
set like this:
|
||||
|
||||
```console
|
||||
$ DOCKER_TMPDIR=/mnt/disk2/tmp /usr/local/bin/dockerd -D -g /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1
|
||||
$ DOCKER_TMPDIR=/mnt/disk2/tmp /usr/local/bin/dockerd --data-root /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```console
|
||||
$ export DOCKER_TMPDIR=/mnt/disk2/tmp
|
||||
$ /usr/local/bin/dockerd -D -g /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1
|
||||
$ /usr/local/bin/dockerd --data-root /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1
|
||||
````
|
||||
|
||||
#### Default cgroup parent
|
||||
@ -1360,11 +1351,11 @@ This is a full example of the allowed configuration options on Linux:
|
||||
"debug": true,
|
||||
"default-address-pools": [
|
||||
{
|
||||
"base": "172.80.0.0/16",
|
||||
"base": "172.30.0.0/16",
|
||||
"size": 24
|
||||
},
|
||||
{
|
||||
"base": "172.90.0.0/16",
|
||||
"base": "172.31.0.0/16",
|
||||
"size": 24
|
||||
}
|
||||
],
|
||||
@ -1462,7 +1453,7 @@ This is a full example of the allowed configuration options on Linux:
|
||||
> daemon startup as a flag.
|
||||
> On systems that use `systemd` to start the Docker daemon, `-H` is already set, so
|
||||
> you cannot use the `hosts` key in `daemon.json` to add listening addresses.
|
||||
> See https://docs.docker.com/engine/admin/systemd/#custom-docker-daemon-options for how
|
||||
> See ["custom Docker daemon options"](https://docs.docker.com/config/daemon/systemd/#custom-docker-daemon-options) for how
|
||||
> to accomplish this task with a systemd drop-in file.
|
||||
|
||||
##### On Windows
|
||||
@ -1554,7 +1545,7 @@ The list of currently supported options that can be reconfigured is this:
|
||||
be used to run containers.
|
||||
- `authorization-plugin`: it specifies the authorization plugins to use.
|
||||
- `allow-nondistributable-artifacts`: Replaces the set of registries to which the daemon will push nondistributable artifacts with a new set of registries.
|
||||
- `insecure-registries`: it replaces the daemon insecure registries with a new set of insecure registries. If some existing insecure registries in daemon's configuration are not in newly reloaded insecure resgitries, these existing ones will be removed from daemon's config.
|
||||
- `insecure-registries`: it replaces the daemon insecure registries with a new set of insecure registries. If some existing insecure registries in daemon's configuration are not in newly reloaded insecure registries, these existing ones will be removed from daemon's config.
|
||||
- `registry-mirrors`: it replaces the daemon registry mirrors with a new set of registry mirrors. If some existing registry mirrors in daemon's configuration are not in newly reloaded registry mirrors, these existing ones will be removed from daemon's config.
|
||||
- `shutdown-timeout`: it replaces the daemon's existing configuration timeout with a new timeout for shutting down all containers.
|
||||
- `features`: it explicitly enables or disables specific features.
|
||||
|
||||
@ -194,11 +194,11 @@ The currently supported filters are:
|
||||
|
||||
If a format (`--format`) is specified, the given template will be executed
|
||||
instead of the default
|
||||
format. Go's [text/template](http://golang.org/pkg/text/template/) package
|
||||
format. Go's [text/template](https://golang.org/pkg/text/template/) package
|
||||
describes all the details of the format.
|
||||
|
||||
If a format is set to `{{json .}}`, the events are streamed as valid JSON
|
||||
Lines. For information about JSON Lines, please refer to http://jsonlines.org/.
|
||||
Lines. For information about JSON Lines, please refer to https://jsonlines.org/.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -208,13 +208,13 @@ You'll need two shells for this example.
|
||||
|
||||
**Shell 1: Listening for events:**
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker events
|
||||
```
|
||||
|
||||
**Shell 2: Start and Stop containers:**
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker create --name test alpine:latest top
|
||||
$ docker start test
|
||||
$ docker stop test
|
||||
@ -239,7 +239,7 @@ To exit the `docker events` command, use `CTRL+C`.
|
||||
You can filter the output by an absolute timestamp or relative time on the host
|
||||
machine, using the following different time syntaxes:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker events --since 1483283804
|
||||
2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)
|
||||
2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)
|
||||
@ -292,7 +292,7 @@ $ docker events --since '2017-01-05T00:35:30' --until '2017-01-05T00:36:05'
|
||||
The following commands show several different ways to filter the `docker event`
|
||||
output.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker events --filter 'event=stop'
|
||||
|
||||
2017-01-05T00:40:22.880175420+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
@ -388,7 +388,7 @@ $ docker events --filter 'scope=swarm'
|
||||
|
||||
### Format the output
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker events --filter 'type=container' --format 'Type={{.Type}} Status={{.Status}} ID={{.ID}}'
|
||||
|
||||
Type=container Status=create ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
@ -401,7 +401,7 @@ Type=container Status=destroy ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299
|
||||
|
||||
#### Format as JSON
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker events --format '{{json .}}'
|
||||
|
||||
{"status":"create","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4..
|
||||
|
||||
@ -46,7 +46,7 @@ not work, but `docker exec -ti my_container sh -c "echo a && echo b"` will.
|
||||
|
||||
First, start a container.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker run --name ubuntu_bash --rm -i -t ubuntu bash
|
||||
```
|
||||
|
||||
@ -54,7 +54,7 @@ This will create a container named `ubuntu_bash` and start a Bash session.
|
||||
|
||||
Next, execute a command on the container.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker exec -d ubuntu_bash touch /tmp/execWorks
|
||||
```
|
||||
|
||||
@ -63,7 +63,7 @@ This will create a new file `/tmp/execWorks` inside the running container
|
||||
|
||||
Next, execute an interactive `bash` shell on the container.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker exec -it ubuntu_bash bash
|
||||
```
|
||||
|
||||
@ -71,7 +71,7 @@ This will create a new Bash session in the container `ubuntu_bash`.
|
||||
|
||||
Next, set an environment variable in the current bash session.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker exec -it -e VAR=1 ubuntu_bash bash
|
||||
```
|
||||
|
||||
@ -81,14 +81,14 @@ on the current Bash session.
|
||||
|
||||
By default `docker exec` command runs in the same working directory set when container was created.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker exec -it ubuntu_bash pwd
|
||||
/
|
||||
```
|
||||
|
||||
You can select working directory for the command to execute into
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker exec -it -w /root ubuntu_bash pwd
|
||||
/root
|
||||
```
|
||||
@ -98,7 +98,7 @@ $ docker exec -it -w /root ubuntu_bash pwd
|
||||
|
||||
If the container is paused, then the `docker exec` command will fail with an error:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker pause test
|
||||
|
||||
test
|
||||
|
||||
@ -30,10 +30,10 @@ in the user guide for examples on exporting data in a volume.
|
||||
|
||||
Each of these commands has the same result.
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker export red_panda > latest.tar
|
||||
```
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker export --output="latest.tar" red_panda
|
||||
```
|
||||
|
||||
@ -24,7 +24,7 @@ Options:
|
||||
|
||||
To see how the `docker:latest` image was built:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker history docker
|
||||
|
||||
IMAGE CREATED CREATED BY SIZE COMMENT
|
||||
@ -38,7 +38,7 @@ be51b77efb42 8 days ago /bin/sh -c apt-get update && apt-get ins
|
||||
|
||||
To see how the `docker:apache` image was added to a container's base image:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker history docker:scm
|
||||
IMAGE CREATED CREATED BY SIZE COMMENT
|
||||
2ac9d1098bf1 3 months ago /bin/bash 241.4 MB Added Apache to Fedora base image
|
||||
@ -54,14 +54,14 @@ using a Go template.
|
||||
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
| Placeholder | Description |
|
||||
| --------------- | ----------- |
|
||||
| `.ID` | Image ID |
|
||||
| Placeholder | Description |
|
||||
|-----------------|-----------------------------------------------------------------------------------------------------------|
|
||||
| `.ID` | Image ID |
|
||||
| `.CreatedSince` | Elapsed time since the image was created if `--human=true`, otherwise timestamp of when image was created |
|
||||
| `.CreatedAt` | Timestamp of when image was created |
|
||||
| `.CreatedBy` | Command that was used to create the image |
|
||||
| `.Size` | Image disk size |
|
||||
| `.Comment` | Comment for image |
|
||||
| `.CreatedAt` | Timestamp of when image was created |
|
||||
| `.CreatedBy` | Command that was used to create the image |
|
||||
| `.Size` | Image disk size |
|
||||
| `.Comment` | Comment for image |
|
||||
|
||||
When using the `--format` option, the `history` command will either
|
||||
output the data exactly as the template declares or, when using the
|
||||
@ -71,7 +71,7 @@ The following example uses a template without headers and outputs the
|
||||
`ID` and `CreatedSince` entries separated by a colon (`:`) for the `busybox`
|
||||
image:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker history --format "{{.ID}}: {{.CreatedSince}}" busybox
|
||||
|
||||
f6e427c148a7: 4 weeks ago
|
||||
|
||||
@ -26,7 +26,7 @@ Remove all dangling images. If `-a` is specified, will also remove all images no
|
||||
|
||||
Example output:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker image prune -a
|
||||
|
||||
WARNING! This will remove all images without at least one container associated to them.
|
||||
@ -101,7 +101,7 @@ images without the specified labels.
|
||||
|
||||
The following removes images created before `2017-01-04T00:00:00`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker images --format 'table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedAt}}\t{{.Size}}'
|
||||
REPOSITORY TAG IMAGE ID CREATED AT SIZE
|
||||
foo latest 2f287ac753da 2017-01-04 13:42:23 -0800 PST 3.98 MB
|
||||
@ -128,7 +128,7 @@ foo latest 2f287ac753da 2017-01-04 13:42:23
|
||||
|
||||
The following removes images created more than 10 days (`240h`) ago:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
@ -168,25 +168,25 @@ busybox latest e02e811dd08f 2 months ago
|
||||
|
||||
The following example removes images with the label `deprecated`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker image prune --filter="label=deprecated"
|
||||
```
|
||||
|
||||
The following example removes images with the label `maintainer` set to `john`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker image prune --filter="label=maintainer=john"
|
||||
```
|
||||
|
||||
This example removes images which have no `maintainer` label:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker image prune --filter="label!=maintainer"
|
||||
```
|
||||
|
||||
This example removes images which have a maintainer label not set to `john`:
|
||||
|
||||
```bash
|
||||
```console
|
||||
$ docker image prune --filter="label!=maintainer=john"
|
||||
```
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user