Compare commits
192 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 715524332f | |||
| e75544f9a7 | |||
| d4cfac0100 | |||
| 913fa471ad | |||
| 1686805f63 | |||
| 91c1ac42ba | |||
| d512c700d1 | |||
| e4d3f5ebe3 | |||
| fa47dff923 | |||
| c6ddb858ca | |||
| 8406d5481d | |||
| c01f45379a | |||
| fb1fb991f2 | |||
| 8dcfddb49a | |||
| fe865e204b | |||
| abdb676065 | |||
| 6ebafa92c1 | |||
| 65a6660652 | |||
| 7ae0f9da1a | |||
| 9e0f8321c4 | |||
| ba33d2f29a | |||
| 22bbb73a12 | |||
| 45fa7f79d3 | |||
| 2eb37e2299 | |||
| 6bc0539acb | |||
| d6d4612bcc | |||
| 70b1300db6 | |||
| d22e65f37f | |||
| b0f80daaeb | |||
| ee608d2713 | |||
| 1cad30bfe2 | |||
| 88d09e8fbd | |||
| 1ca0b09336 | |||
| 06faf2b40e | |||
| b309569bc6 | |||
| 9889fa575a | |||
| 5069f9f739 | |||
| b33c935a05 | |||
| 8267254803 | |||
| c264374cb8 | |||
| cd3c5adce8 | |||
| 6022ae7439 | |||
| 524dcda649 | |||
| 6e1e509408 | |||
| 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 |
@ -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
|
||||
|
||||
24
Dockerfile
24
Dockerfile
@ -1,23 +1,13 @@
|
||||
# syntax=docker/dockerfile:1.3
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG BASE_VARIANT=alpine
|
||||
ARG GO_VERSION=1.16.12
|
||||
ARG XX_VERSION=1.0.0-rc.2
|
||||
|
||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${BASE_VARIANT} AS gostable
|
||||
FROM --platform=$BUILDPLATFORM golang:1.17rc1-${BASE_VARIANT} AS golatest
|
||||
|
||||
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
|
||||
ARG GO_VERSION=1.18.10
|
||||
ARG ALPINE_VERSION=3.16
|
||||
ARG XX_VERSION=1.1.0
|
||||
|
||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} 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
|
||||
@ -27,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
|
||||
@ -55,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.12
|
||||
GOVERSION: 1.18.10
|
||||
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
|
||||
|
||||
@ -210,9 +210,13 @@ func isExperimental(cmd *cobra.Command) bool {
|
||||
}
|
||||
|
||||
func additionalHelp(cmd *cobra.Command) string {
|
||||
if additionalHelp, ok := cmd.Annotations["additionalHelp"]; ok {
|
||||
if msg, ok := cmd.Annotations["additionalHelp"]; ok {
|
||||
out := cmd.OutOrStderr()
|
||||
if _, isTerminal := term.GetFdInfo(out); !isTerminal {
|
||||
return msg
|
||||
}
|
||||
style := aec.EmptyBuilder.Bold().ANSI
|
||||
return style.Apply(additionalHelp)
|
||||
return style.Apply(msg)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -379,6 +383,7 @@ Run '{{.CommandPath}} COMMAND --help' for more information on a command.
|
||||
{{- if hasAdditionalHelp .}}
|
||||
|
||||
{{ additionalHelp . }}
|
||||
|
||||
{{- end}}
|
||||
`
|
||||
|
||||
|
||||
@ -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}}"},
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"sort"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
@ -14,33 +15,46 @@ import (
|
||||
)
|
||||
|
||||
func TestRemoveForce(t *testing.T) {
|
||||
var removed []string
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
args []string
|
||||
expectedErr string
|
||||
}{
|
||||
{name: "without force", args: []string{"nosuchcontainer", "mycontainer"}, expectedErr: "no such container"},
|
||||
{name: "with force", args: []string{"--force", "nosuchcontainer", "mycontainer"}, expectedErr: ""},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var removed []string
|
||||
mutex := new(sync.Mutex)
|
||||
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
containerRemoveFunc: func(ctx context.Context, container string, options types.ContainerRemoveOptions) error {
|
||||
removed = append(removed, container)
|
||||
if container == "nosuchcontainer" {
|
||||
return errdefs.NotFound(fmt.Errorf("Error: No such container: " + container))
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
containerRemoveFunc: func(ctx context.Context, container string, options types.ContainerRemoveOptions) error {
|
||||
// containerRemoveFunc is called in parallel for each container
|
||||
// by the remove command so append must be synchronized.
|
||||
mutex.Lock()
|
||||
removed = append(removed, container)
|
||||
mutex.Unlock()
|
||||
|
||||
if container == "nosuchcontainer" {
|
||||
return errdefs.NotFound(fmt.Errorf("Error: no such container: " + container))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Version: "1.36",
|
||||
})
|
||||
cmd := NewRmCommand(cli)
|
||||
cmd.SetOut(ioutil.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
|
||||
err := cmd.Execute()
|
||||
if tc.expectedErr != "" {
|
||||
assert.ErrorContains(t, err, tc.expectedErr)
|
||||
} else {
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Version: "1.36",
|
||||
})
|
||||
cmd := NewRmCommand(cli)
|
||||
cmd.SetOut(ioutil.Discard)
|
||||
|
||||
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"})
|
||||
})
|
||||
t.Run("with force", func(t *testing.T) {
|
||||
cmd.SetArgs([]string{"--force", "nosuchcontainer", "mycontainer"})
|
||||
removed = []string{}
|
||||
assert.NilError(t, cmd.Execute())
|
||||
sort.Strings(removed)
|
||||
assert.DeepEqual(t, removed, []string{"mycontainer", "nosuchcontainer"})
|
||||
})
|
||||
sort.Strings(removed)
|
||||
assert.DeepEqual(t, removed, []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",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -506,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
|
||||
@ -2771,8 +2771,8 @@ __docker_subcommand() {
|
||||
"($help)--live-restore[Enable live restore of docker when containers are still running]" \
|
||||
"($help)--log-driver=[Default driver for container logs]:logging driver:__docker_complete_log_drivers" \
|
||||
"($help)*--log-opt=[Default log driver options for containers]:log driver options:__docker_complete_log_options" \
|
||||
"($help)--max-concurrent-downloads[Set the max concurrent downloads for each pull]" \
|
||||
"($help)--max-concurrent-uploads[Set the max concurrent uploads for each push]" \
|
||||
"($help)--max-concurrent-downloads[Set the max concurrent downloads]" \
|
||||
"($help)--max-concurrent-uploads[Set the max concurrent uploads]" \
|
||||
"($help)--max-download-attempts[Set the max download attempts for each pull]" \
|
||||
"($help)--mtu=[Network MTU]:mtu:(0 576 1420 1500 9000)" \
|
||||
"($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \
|
||||
@ -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.10"
|
||||
}
|
||||
variable "VERSION" {
|
||||
default = ""
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
ARG GO_VERSION=1.16.10
|
||||
ARG GO_VERSION=1.18.10
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
# syntax=docker/dockerfile:1.3
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.16.12
|
||||
ARG GO_VERSION=1.18.10
|
||||
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.10
|
||||
ARG GO_VERSION=1.18.10
|
||||
|
||||
# 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.12
|
||||
ARG GOLANGCI_LINTER_SHA="v1.21.0"
|
||||
ARG GO_VERSION=1.18.10
|
||||
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,74 @@ 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 | [Btrfs storage driver on CentOS 7 and RHEL 7](#btrfs-storage-driver-on-centos-7-and-rhel-7) | v20.10 | - |
|
||||
| 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 |
|
||||
|
||||
|
||||
### Btrfs storage driver on CentOS 7 and RHEL 7
|
||||
|
||||
**Deprecated in Release: v20.10.0**
|
||||
|
||||
**Target For Removal In Release: v23.0.0**
|
||||
|
||||
The `btrfs` storage driver on CentOS and RHEL was provided as a technology preview
|
||||
by CentOS and RHEL, but has been deprecated since the [Red Hat Enterprise Linux 7.4 release](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/ch-btrfs),
|
||||
and removed in CentOS 8 and RHEL 8. Users of the `btrfs` storage driver on CentOS
|
||||
are recommended to migrate to a different storage driver, such as `overlay2`, which
|
||||
is now the default storage driver. Docker 23.0 continues to provide the `btrfs`
|
||||
storage driver to allow users to migrate to an alternative driver. The next release
|
||||
of Docker will no longer provide this driver.
|
||||
|
||||
### Support for encrypted TLS private keys
|
||||
|
||||
@ -254,6 +272,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 +340,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
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
description: "How develop and use a plugin with the managed plugin system"
|
||||
description: "How to develop and use a plugin with the managed plugin system"
|
||||
keywords: "API, Usage, plugins, documentation, developer"
|
||||
---
|
||||
|
||||
@ -15,17 +15,14 @@ keywords: "API, Usage, plugins, documentation, developer"
|
||||
|
||||
# Plugin Config Version 1 of Plugin V2
|
||||
|
||||
This document outlines the format of the V0 plugin configuration. The plugin
|
||||
config described herein was introduced in the Docker daemon in the [v1.12.0
|
||||
release](https://github.com/docker/docker/commit/f37117045c5398fd3dca8016ea8ca0cb47e7312b).
|
||||
This document outlines the format of the V0 plugin configuration.
|
||||
|
||||
Plugin configs describe the various constituents of a docker plugin. Plugin
|
||||
configs can be serialized to JSON format with the following media types:
|
||||
|
||||
Config Type | Media Type
|
||||
------------- | -------------
|
||||
config | "application/vnd.docker.plugin.v1+json"
|
||||
|
||||
| Config Type | Media Type |
|
||||
|-------------|-----------------------------------------|
|
||||
| config | "application/vnd.docker.plugin.v1+json" |
|
||||
|
||||
## *Config* Field Descriptions
|
||||
|
||||
|
||||
@ -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.
|
||||
@ -70,7 +70,7 @@ 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`.
|
||||
|
||||
@ -115,6 +115,7 @@ enabled, and use it to create a volume.
|
||||
```
|
||||
|
||||
6. Remove the volume `sshvolume`
|
||||
|
||||
```console
|
||||
$ docker volume rm sshvolume
|
||||
|
||||
@ -126,15 +127,15 @@ 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.
|
||||
|
||||
```console
|
||||
$ git clone https://github.com/vieux/docker-volume-sshfs
|
||||
@ -155,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"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -187,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
|
||||
@ -226,7 +226,7 @@ plugins. This is specifically useful to collect plugin logs if they are
|
||||
redirected to a file.
|
||||
|
||||
```console
|
||||
$ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins list
|
||||
$ 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
|
||||
@ -235,14 +235,14 @@ c5bb4b90941efcaccca999439ed06d6a6affdde7081bb34dc84126b57b3e793d 14984 r
|
||||
```
|
||||
|
||||
```console
|
||||
$ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins exec 93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 cat /var/log/plugin.log
|
||||
$ 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:
|
||||
|
||||
```console
|
||||
$ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins exec -t 93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 sh
|
||||
$ sudo runc --root /run/docker/runtime-runc/plugins.moby exec -t 93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 sh
|
||||
```
|
||||
|
||||
#### Using curl to debug plugin socket issues.
|
||||
@ -253,7 +253,6 @@ 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>`
|
||||
|
||||
|
||||
```console
|
||||
$ curl -H "Content-Type: application/json" -XPOST -d '{}' --unix-socket /var/run/docker/plugins/e8a37ba56fc879c991f7d7921901723c64df6b42b87e6a0b055771ecf8477a6d/plugin.sock http:/VolumeDriver.List
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ The sections below provide an inexhaustive overview of available plugins.
|
||||
| [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](https://www.quobyte.com/containers)'s data center file system, a general-purpose scalable and fault-tolerant storage platform. |
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1060,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:
|
||||
@ -1632,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):
|
||||
@ -1640,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`.
|
||||
@ -1654,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
|
||||
|
||||
@ -1824,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
|
||||
|
||||
@ -45,12 +45,12 @@ a container and leave it running using the `CTRL-p CTRL-q` key sequence.
|
||||
> so.
|
||||
|
||||
It is forbidden to redirect the standard input of a `docker attach` command
|
||||
while attaching to a tty-enabled container (i.e.: launched with `-t`).
|
||||
while attaching to a TTY-enabled container (using the `-i` and `-t` options).
|
||||
|
||||
While a client is connected to container's stdio using `docker attach`, Docker
|
||||
uses a ~1MB memory buffer to maximize the throughput of the application. If
|
||||
this buffer is filled, the speed of the API connection will start to have an
|
||||
effect on the process output writing speed. This is similar to other
|
||||
While a client is connected to container's `stdio` using `docker attach`, Docker
|
||||
uses a ~1MB memory buffer to maximize the throughput of the application.
|
||||
Once this buffer is full, the speed of the API connection is affected, and so
|
||||
this impacts the output process' writing speed. This is similar to other
|
||||
applications like SSH. Because of this, it is not recommended to run
|
||||
performance critical applications that generate a lot of output in the
|
||||
foreground over a slow client connection. Instead, users should use the
|
||||
@ -84,45 +84,68 @@ containers, see [**Configuration file** section](cli.md#configuration-files).
|
||||
|
||||
### Attach to and detach from a running container
|
||||
|
||||
The following example starts an ubuntu container running `top` in detached mode,
|
||||
then attaches to the container;
|
||||
|
||||
```console
|
||||
$ docker run -d --name topdemo ubuntu /usr/bin/top -b
|
||||
$ docker run -d --name topdemo ubuntu:22.04 /usr/bin/top -b
|
||||
|
||||
$ docker attach topdemo
|
||||
|
||||
top - 02:05:52 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
|
||||
top - 12:27:44 up 3 days, 21:54, 0 users, load average: 0.00, 0.00, 0.00
|
||||
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
||||
Cpu(s): 0.1%us, 0.2%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
|
||||
Mem: 373572k total, 355560k used, 18012k free, 27872k buffers
|
||||
Swap: 786428k total, 0k used, 786428k free, 221740k cached
|
||||
%Cpu(s): 0.1 us, 0.1 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
|
||||
MiB Mem : 3934.3 total, 770.1 free, 674.2 used, 2490.1 buff/cache
|
||||
MiB Swap: 1024.0 total, 839.3 free, 184.7 used. 2814.0 avail Mem
|
||||
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 7180 2896 2568 R 0.0 0.1 0:00.02 top
|
||||
```
|
||||
|
||||
top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
|
||||
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
||||
Cpu(s): 0.0%us, 0.2%sy, 0.0%ni, 99.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
|
||||
Mem: 373572k total, 355244k used, 18328k free, 27872k buffers
|
||||
Swap: 786428k total, 0k used, 786428k free, 221776k cached
|
||||
As the container was started without the `-i`, and `-t` options, signals are
|
||||
forwarded to the attached process, which means that the default `CTRL-p CTRL-q`
|
||||
detach key sequence produces no effect, but pressing `CTRL-c` terminates the
|
||||
container:
|
||||
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
|
||||
```console
|
||||
<...>
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 7180 2896 2568 R 0.0 0.1 0:00.02 top^P^Q
|
||||
^C
|
||||
|
||||
$ docker ps -a --filter name=topdemo
|
||||
|
||||
top - 02:05:58 up 3:06, 0 users, load average: 0.01, 0.02, 0.05
|
||||
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
||||
Cpu(s): 0.2%us, 0.3%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
|
||||
Mem: 373572k total, 355780k used, 17792k free, 27880k buffers
|
||||
Swap: 786428k total, 0k used, 786428k free, 221776k cached
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
4cf0d0ebb079 ubuntu:22.04 "/usr/bin/top -b" About a minute ago Exited (0) About a minute ago topdemo
|
||||
```
|
||||
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
|
||||
^C$
|
||||
Repeating the example above, but this time with the `-i` and `-t` options set;
|
||||
|
||||
$ echo $?
|
||||
0
|
||||
$ docker ps -a | grep topdemo
|
||||
```console
|
||||
$ docker run -dit --name topdemo2 ubuntu:22.04 /usr/bin/top -b
|
||||
```
|
||||
|
||||
7998ac8581f9 ubuntu:14.04 "/usr/bin/top -b" 38 seconds ago Exited (0) 21 seconds ago topdemo
|
||||
Now, when attaching to the container, and pressing the `CTRL-p CTRL-q` ("read
|
||||
escape sequence"), the Docker CLI is handling the detach sequence, and the
|
||||
`attach` command is detached from the container. Checking the container's status
|
||||
with `docker ps` shows that the container is still running in the background:
|
||||
|
||||
```console
|
||||
$ docker attach topdemo2
|
||||
|
||||
top - 12:44:32 up 3 days, 22:11, 0 users, load average: 0.00, 0.00, 0.00
|
||||
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
||||
%Cpu(s): 50.0 us, 0.0 sy, 0.0 ni, 50.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
|
||||
MiB Mem : 3934.3 total, 770.6 free, 672.4 used, 2491.4 buff/cache
|
||||
MiB Swap: 1024.0 total, 839.3 free, 184.7 used. 2815.8 avail Mem
|
||||
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 7180 2776 2452 R 0.0 0.1 0:00.02 topread escape sequence
|
||||
|
||||
$ docker ps -a --filter name=topdemo2
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
b1661dce0fc2 ubuntu:22.04 "/usr/bin/top -b" 2 minutes ago Up 2 minutes topdemo2
|
||||
```
|
||||
|
||||
### Get the exit code of the container's command
|
||||
@ -131,18 +154,17 @@ 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:
|
||||
|
||||
```console
|
||||
$ docker run --name test -d -it debian
|
||||
$ docker run --name test -dit alpine
|
||||
275c44472aebd77c926d4527885bb09f2f6db21d878c75f0a1c212c03d3bcfab
|
||||
|
||||
$ docker attach test
|
||||
root@f38c87f2a42d:/# exit 13
|
||||
|
||||
exit
|
||||
/# exit 13
|
||||
|
||||
$ echo $?
|
||||
13
|
||||
|
||||
$ docker ps -a | grep test
|
||||
$ docker ps -a --filter name=test
|
||||
|
||||
275c44472aeb debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
a2fe3fd886db alpine "/bin/sh" About a minute ago Exited (13) 40 seconds ago test
|
||||
```
|
||||
|
||||
@ -99,16 +99,16 @@ $ 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**
|
||||
>
|
||||
@ -323,16 +323,16 @@ 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)
|
||||
### <a name="tag"></a> Tag an image (-t, --tag)
|
||||
|
||||
```console
|
||||
$ docker build -t vieux/apache:2.0 .
|
||||
@ -352,7 +352,7 @@ For example, to tag an image both as `whenry/fedora-jboss:latest` and
|
||||
$ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .
|
||||
```
|
||||
|
||||
### Specify a Dockerfile (-f)
|
||||
### <a name="file"></a> Specify a Dockerfile (-f, --file)
|
||||
|
||||
```console
|
||||
$ docker build -f Dockerfile.debug .
|
||||
@ -399,17 +399,17 @@ the command line.
|
||||
> repeatable builds on remote Docker hosts. This is also the reason why
|
||||
> `ADD ../file` does not work.
|
||||
|
||||
### Use a custom parent cgroup (--cgroup-parent)
|
||||
### <a name="cgroup-parent"></a> Use a custom parent cgroup (--cgroup-parent)
|
||||
|
||||
When `docker build` is run with the `--cgroup-parent` option the containers
|
||||
used in the build will be run with the [corresponding `docker run` flag](../run.md#specify-custom-cgroups).
|
||||
|
||||
### Set ulimits in container (--ulimit)
|
||||
### <a name="ulimit"></a> Set ulimits in container (--ulimit)
|
||||
|
||||
Using the `--ulimit` option with `docker build` will cause each build step's
|
||||
container to be started using those [`--ulimit` flag values](run.md#set-ulimits-in-container---ulimit).
|
||||
container to be started using those [`--ulimit` flag values](run.md#ulimit).
|
||||
|
||||
### Set build-time variables (--build-arg)
|
||||
### <a name="build-arg"></a> Set build-time variables (--build-arg)
|
||||
|
||||
You can use `ENV` instructions in a Dockerfile to define variable
|
||||
values. These values persist in the built image. However, often
|
||||
@ -444,16 +444,16 @@ $ export HTTP_PROXY=http://10.20.30.2:1234
|
||||
$ docker build --build-arg HTTP_PROXY .
|
||||
```
|
||||
|
||||
This is similar to how `docker run -e` works. Refer to the [`docker run` documentation](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)
|
||||
This is similar to how `docker run -e` works. Refer to the [`docker run` documentation](run.md#env)
|
||||
for more information.
|
||||
|
||||
### Optional security options (--security-opt)
|
||||
### <a name="security-opt"></a> Optional security options (--security-opt)
|
||||
|
||||
This flag is only supported on a daemon running on Windows, and only supports
|
||||
the `credentialspec` option. The `credentialspec` must be in the format
|
||||
`file://spec.txt` or `registry://keyname`.
|
||||
|
||||
### Specify isolation technology for container (--isolation)
|
||||
### <a name="isolation"></a> 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
|
||||
@ -461,15 +461,15 @@ 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"`.
|
||||
|
||||
### Add entries to container hosts file (--add-host)
|
||||
### <a name="add-host"></a> Add entries to container hosts file (--add-host)
|
||||
|
||||
You can add other hosts into a container's `/etc/hosts` file by using one or
|
||||
more `--add-host` flags. This example adds a static address for a host named
|
||||
@ -477,7 +477,7 @@ more `--add-host` flags. This example adds a static address for a host named
|
||||
|
||||
$ docker build --add-host=docker:10.180.0.1 .
|
||||
|
||||
### Specifying target build stage (--target)
|
||||
### <a name="target"></a> Specifying target build stage (--target)
|
||||
|
||||
When building a Dockerfile with multiple build stages, `--target` can be used to
|
||||
specify an intermediate build stage by name as a final stage for the resulting
|
||||
@ -485,17 +485,24 @@ image. Commands after the target stage will be skipped.
|
||||
|
||||
```dockerfile
|
||||
FROM debian AS build-env
|
||||
...
|
||||
# ...
|
||||
|
||||
FROM alpine AS production-env
|
||||
...
|
||||
# ...
|
||||
```
|
||||
|
||||
```console
|
||||
$ docker build -t mybuildimage --target build-env .
|
||||
```
|
||||
|
||||
### Custom build outputs
|
||||
### <a name="output"></a> Custom build outputs (--output)
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> This feature requires the BuildKit backend. You can either
|
||||
> [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.
|
||||
|
||||
By default, a local container image is created from the build result. The
|
||||
`--output` (or `-o`) flag allows you to override this behavior, and a specify a
|
||||
@ -582,13 +589,14 @@ $ ls ./out
|
||||
vndr
|
||||
```
|
||||
|
||||
### <a name="cache-from"></a> Specifying external cache sources (--cache-from)
|
||||
|
||||
> **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.
|
||||
|
||||
### Specifying external cache sources
|
||||
> [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.
|
||||
|
||||
In addition to local build cache, the builder can reuse the cache generated from
|
||||
previous builds with the `--cache-from` flag pointing to an image in the registry.
|
||||
@ -624,14 +632,7 @@ On another machine:
|
||||
$ 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.
|
||||
|
||||
### Squash an image's layers (--squash) (experimental)
|
||||
### <a name="squash"></a> Squash an image's layers (--squash) (experimental)
|
||||
|
||||
#### Overview
|
||||
|
||||
|
||||
@ -78,7 +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](../builder.md#buildkit). Use plain to show container output (default `auto`). |
|
||||
| `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:
|
||||
@ -154,17 +154,17 @@ different location.
|
||||
These fields allow you to customize the default output format for some commands
|
||||
if no `--format` flag is provided.
|
||||
|
||||
| Property | Description |
|
||||
|:-----------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `configFormat` | Custom default format for `docker config ls` output. Refer to the [**format the output** section in the `docker config ls` documentation](config_ls.md#format-the-output) for a list of supported formatting directives. |
|
||||
| `imagesFormat` | Custom default format for `docker images` / `docker image ls` output. Refer to the [**format the output** section in the `docker images` documentation](images.md#format-the-output) for a list of supported formatting directives. |
|
||||
| `nodesFormat` | Custom default format for `docker node ls` output. Refer to the [**formatting** section in the `docker node ls` documentation](node_ls.md#formatting) for a list of supported formatting directives. |
|
||||
| `pluginsFormat` | Custom default format for `docker plugin ls` output. Refer to the [**formatting** section in the `docker plugin ls` documentation](plugin_ls.md#formatting) for a list of supported formatting directives. |
|
||||
| `psFormat` | Custom default format for `docker ps` / `docker container ps` output. Refer to the [**formatting** section in the `docker ps` documentation](ps.md#formatting) for a list of supported formatting directives. |
|
||||
| `secretFormat` | Custom default format for `docker secret ls` output. Refer to the [**format the output** section in the `docker secret ls` documentation](secret_ls.md#format-the-output) for a list of supported formatting directives. |
|
||||
| `serviceInspectFormat` | Custom default format for `docker service inspect` output. Refer to the [**formatting** section in the `docker service inspect` documentation](service_inspect.md#formatting) for a list of supported formatting directives. |
|
||||
| `servicesFormat` | Custom default format for `docker service ls` output. Refer to the [**formatting** section in the `docker service ls` documentation](service_ls.md#formatting) for a list of supported formatting directives. |
|
||||
| `statsFormat` | Custom default format for `docker stats` output. Refer to the [**formatting** section in the `docker stats` documentation](stats.md#formatting) for a list of supported formatting directives. |
|
||||
| Property | Description |
|
||||
|:-----------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `configFormat` | Custom default format for `docker config ls` output. Refer to the [**format the output** section in the `docker config ls` documentation](config_ls.md#format) for a list of supported formatting directives. |
|
||||
| `imagesFormat` | Custom default format for `docker images` / `docker image ls` output. Refer to the [**format the output** section in the `docker images` documentation](images.md#format) for a list of supported formatting directives. |
|
||||
| `nodesFormat` | Custom default format for `docker node ls` output. Refer to the [**formatting** section in the `docker node ls` documentation](node_ls.md#format) for a list of supported formatting directives. |
|
||||
| `pluginsFormat` | Custom default format for `docker plugin ls` output. Refer to the [**formatting** section in the `docker plugin ls` documentation](plugin_ls.md#format) for a list of supported formatting directives. |
|
||||
| `psFormat` | Custom default format for `docker ps` / `docker container ps` output. Refer to the [**formatting** section in the `docker ps` documentation](ps.md#format) for a list of supported formatting directives. |
|
||||
| `secretFormat` | Custom default format for `docker secret ls` output. Refer to the [**format the output** section in the `docker secret ls` documentation](secret_ls.md#format) for a list of supported formatting directives. |
|
||||
| `serviceInspectFormat` | Custom default format for `docker service inspect` output. Refer to the [**formatting** section in the `docker service inspect` documentation](service_inspect.md#format) for a list of supported formatting directives. |
|
||||
| `servicesFormat` | Custom default format for `docker service ls` output. Refer to the [**formatting** section in the `docker service ls` documentation](service_ls.md#format) for a list of supported formatting directives. |
|
||||
| `statsFormat` | Custom default format for `docker stats` output. Refer to the [**formatting** section in the `docker stats` documentation](stats.md#format) for a list of supported formatting directives. |
|
||||
|
||||
|
||||
### Custom HTTP headers
|
||||
|
||||
@ -47,8 +47,8 @@ created. Supported `Dockerfile` instructions:
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
c3f279d17e0a ubuntu:22.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:22.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
|
||||
$ docker commit c3f279d17e0a svendowideit/testimage:version3
|
||||
|
||||
@ -60,14 +60,14 @@ REPOSITORY TAG ID CREATE
|
||||
svendowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB
|
||||
```
|
||||
|
||||
### Commit a container with new configurations
|
||||
### <a name="change"></a> Commit a container with new configurations (--change)
|
||||
|
||||
```console
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
c3f279d17e0a ubuntu:22.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:22.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
|
||||
$ docker inspect -f "{{ .Config.Env }}" c3f279d17e0a
|
||||
|
||||
@ -88,8 +88,8 @@ $ docker inspect -f "{{ .Config.Env }}" f5283438590d
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
c3f279d17e0a ubuntu:22.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:22.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
|
||||
$ docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" c3f279d17e0a svendowideit/testimage:version4
|
||||
|
||||
@ -103,6 +103,6 @@ $ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
89373736e2e7 testimage:version4 "apachectl -DFOREGROU" 3 seconds ago Up 2 seconds 80/tcp distracted_fermat
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
c3f279d17e0a ubuntu:22.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:22.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
```
|
||||
|
||||
@ -57,7 +57,7 @@ ID NAME CREATED UPDATED
|
||||
dg426haahpi5ezmkkj5kyl3sn my_config 7 seconds ago 7 seconds ago
|
||||
```
|
||||
|
||||
### Create a config with labels
|
||||
### <a name="label"></a> Create a config with labels (-l, --label)
|
||||
|
||||
```console
|
||||
$ docker config create \
|
||||
|
||||
@ -77,7 +77,7 @@ The output is in JSON format, for example:
|
||||
]
|
||||
```
|
||||
|
||||
### Formatting
|
||||
### <a name="format"></a> Format the output (--format)
|
||||
|
||||
You can use the --format option to obtain specific information about a
|
||||
config. The following example command outputs the creation time of the
|
||||
|
||||
@ -45,7 +45,7 @@ ID NAME CREATED UPDA
|
||||
mem02h8n73mybpgqjf0kfi1n0 test_config 3 seconds ago 3 seconds ago
|
||||
```
|
||||
|
||||
### Filtering
|
||||
### <a name="filter"></a> Filtering (-f, --filter)
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
@ -105,7 +105,7 @@ ID NAME CREATED UPDA
|
||||
mem02h8n73mybpgqjf0kfi1n0 test_config About an hour ago About an hour ago
|
||||
```
|
||||
|
||||
### Format the output
|
||||
### <a name="format"></a> Format the output (--format)
|
||||
|
||||
The formatting option (`--format`) pretty prints configs output
|
||||
using a Go template.
|
||||
@ -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 |
|
||||
|
||||
@ -37,7 +37,7 @@ f98f9c2aa1eaf727e4ec9c0283bc7d4aa4762fbdba7f26191f26c97f64090360
|
||||
Total reclaimed space: 212 B
|
||||
```
|
||||
|
||||
### Filtering
|
||||
### <a name="filter"></a> Filtering (--filter)
|
||||
|
||||
The filtering flag (`--filter`) format is of "key=value". If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
||||
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)
|
||||
@ -69,7 +69,7 @@ $ docker context create \
|
||||
my-context
|
||||
```
|
||||
|
||||
### Create a context based on an existing context
|
||||
### <a name="from"></a> Create a context based on an existing context (--from)
|
||||
|
||||
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`
|
||||
|
||||
@ -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,8 +89,30 @@ 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
|
||||
`/proc`, `/sys`, `/dev`, [tmpfs](run.md#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):
|
||||
|
||||
@ -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
|
||||
@ -134,35 +135,51 @@ Options:
|
||||
|
||||
## 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
|
||||
|
||||
```console
|
||||
$ 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:
|
||||
|
||||
@ -199,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.
|
||||
|
||||
```console
|
||||
$ 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 solutions 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:
|
||||
|
||||
```console
|
||||
$ 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
|
||||
|
||||
@ -77,8 +77,8 @@ Options:
|
||||
--log-driver string Default driver for container logs (default "json-file")
|
||||
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
|
||||
--log-opt map Default log driver options for containers (default map[])
|
||||
--max-concurrent-downloads int Set the max concurrent downloads for each pull (default 3)
|
||||
--max-concurrent-uploads int Set the max concurrent uploads for each push (default 5)
|
||||
--max-concurrent-downloads int Set the max concurrent downloads (default 3)
|
||||
--max-concurrent-uploads int Set the max concurrent uploads (default 5)
|
||||
--max-download-attempts int Set the max download attempts for each pull (default 5)
|
||||
--metrics-addr string Set default address and port to serve the metrics api on
|
||||
--mtu int Set the containers network MTU
|
||||
@ -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**
|
||||
>
|
||||
@ -312,7 +312,7 @@ 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
|
||||
@ -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 |
|
||||
@ -820,20 +820,11 @@ $ 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
|
||||
|
||||
@ -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
|
||||
@ -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.
|
||||
|
||||
@ -141,7 +141,7 @@ Docker configs report the following events:
|
||||
|
||||
### Limiting, filtering, and formatting the output
|
||||
|
||||
#### Limit events by time
|
||||
#### <a name="since"></a> Limit events by time (--since, --until)
|
||||
|
||||
The `--since` and `--until` parameters can be Unix timestamps, date formatted
|
||||
timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed
|
||||
@ -159,7 +159,7 @@ fraction of a second no more than nine digits long.
|
||||
Only the last 1000 log events are returned. You can use filters to further limit
|
||||
the number of events returned.
|
||||
|
||||
#### Filtering
|
||||
#### <a name="filter"></a> Filtering (--filter)
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If you would
|
||||
like to use multiple filters, pass multiple flags (e.g.,
|
||||
@ -190,7 +190,7 @@ The currently supported filters are:
|
||||
* type (`type=<container or image or volume or network or daemon or plugin or service or node or secret or config>`)
|
||||
* volume (`volume=<name>`)
|
||||
|
||||
#### Format
|
||||
#### <a name="format"></a> Format the output (--format)
|
||||
|
||||
If a format (`--format`) is specified, the given template will be executed
|
||||
instead of the default
|
||||
@ -340,8 +340,8 @@ $ docker events --filter 'type=network'
|
||||
|
||||
$ docker events --filter 'container=container_1' --filter 'container=container_2'
|
||||
|
||||
2014-09-03T15:49:29.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04)
|
||||
2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04)
|
||||
2014-09-03T15:49:29.999999999Z07:00 container die 4386fb97867d (image=ubuntu:22.04)
|
||||
2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu:22.04)
|
||||
2014-05-10T17:42:14.999999999Z07:00 container die 7805c1d35632 (imager=redis:2.8)
|
||||
2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)
|
||||
|
||||
|
||||
@ -32,13 +32,13 @@ The command started using `docker exec` only runs while the container's primary
|
||||
process (`PID 1`) is running, and it is not restarted if the container is
|
||||
restarted.
|
||||
|
||||
COMMAND will run in the default directory of the container. If the
|
||||
underlying image has a custom directory specified with the WORKDIR directive
|
||||
in its Dockerfile, this will be used instead.
|
||||
COMMAND runs in the default directory of the container. If the underlying image
|
||||
has a custom directory specified with the WORKDIR directive in its Dockerfile,
|
||||
this directory is used instead.
|
||||
|
||||
COMMAND should be an executable, a chained or a quoted command
|
||||
will not work. Example: `docker exec -ti my_container "echo a && echo b"` will
|
||||
not work, but `docker exec -ti my_container sh -c "echo a && echo b"` will.
|
||||
COMMAND must be an executable. A chained or a quoted command does not work.
|
||||
For example, `docker exec -it my_container sh -c "echo a && echo b"` works,
|
||||
work, but `docker exec -it my_container "echo a && echo b"` does not.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -47,70 +47,91 @@ not work, but `docker exec -ti my_container sh -c "echo a && echo b"` will.
|
||||
First, start a container.
|
||||
|
||||
```console
|
||||
$ docker run --name ubuntu_bash --rm -i -t ubuntu bash
|
||||
$ docker run --name mycontainer -d -i -t alpine /bin/sh
|
||||
```
|
||||
|
||||
This will create a container named `ubuntu_bash` and start a Bash session.
|
||||
This creates and starts a container named `mycontainer` from an `alpine` image
|
||||
with an `sh` shell as its main process. The `-d` option (shorthand for `--detach`)
|
||||
sets the container to run in the background, in detached mode, with a pseudo-TTY
|
||||
attached (`-t`). The `-i` option is set to keep `STDIN` attached (`-i`), which
|
||||
prevents the `sh` process from exiting immediately.
|
||||
|
||||
Next, execute a command on the container.
|
||||
|
||||
```console
|
||||
$ docker exec -d ubuntu_bash touch /tmp/execWorks
|
||||
$ docker exec -d mycontainer touch /tmp/execWorks
|
||||
```
|
||||
|
||||
This will create a new file `/tmp/execWorks` inside the running container
|
||||
`ubuntu_bash`, in the background.
|
||||
This creates a new file `/tmp/execWorks` inside the running container
|
||||
`mycontainer`, in the background.
|
||||
|
||||
Next, execute an interactive `bash` shell on the container.
|
||||
Next, execute an interactive `sh` shell on the container.
|
||||
|
||||
```console
|
||||
$ docker exec -it ubuntu_bash bash
|
||||
$ docker exec -it mycontainer sh
|
||||
```
|
||||
|
||||
This will create a new Bash session in the container `ubuntu_bash`.
|
||||
This starts a new shell session in the container `mycontainer`.
|
||||
|
||||
Next, set an environment variable in the current bash session.
|
||||
### <a name="env"></a> Set environment variables for the exec process (--env, -e)
|
||||
|
||||
Next, set environment variables in the current bash session.
|
||||
|
||||
By default, the `docker exec` command, inherits the environment variables that
|
||||
are set at the time the container is created. Use the `--env` (or the `-e` shorthand)
|
||||
to override global environment variables, or to set additional environment variables
|
||||
for the process started by `docker exec`.
|
||||
|
||||
The example below creates a new shell session in the container `mycontainer` with
|
||||
environment variables `$VAR_A` and `$VAR_B` set to "1" and "2" respectively.
|
||||
These environment variables are only valid for the `sh` process started by that
|
||||
`docker exec` command, and are not available to other processes running inside
|
||||
the container.
|
||||
|
||||
```console
|
||||
$ docker exec -it -e VAR=1 ubuntu_bash bash
|
||||
$ docker exec -e VAR_A=1 -e VAR_B=2 mycontainer env
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
HOSTNAME=f64a4851eb71
|
||||
VAR_A=1
|
||||
VAR_B=2
|
||||
HOME=/root
|
||||
```
|
||||
|
||||
This will create a new Bash session in the container `ubuntu_bash` with environment
|
||||
variable `$VAR` set to "1". Note that this environment variable will only be valid
|
||||
on the current Bash session.
|
||||
### <a name="workdir"></a> Set the working directory for the exec process (--workdir, -w)
|
||||
|
||||
By default `docker exec` command runs in the same working directory set when container was created.
|
||||
By default `docker exec` command runs in the same working directory set when
|
||||
the container was created.
|
||||
|
||||
```console
|
||||
$ docker exec -it ubuntu_bash pwd
|
||||
$ docker exec -it mycontainer pwd
|
||||
/
|
||||
```
|
||||
|
||||
You can select working directory for the command to execute into
|
||||
You can specify an alternative working directory for the command to execute
|
||||
using the `--workdir` option (or the `-w` shorthand):
|
||||
|
||||
```console
|
||||
$ docker exec -it -w /root ubuntu_bash pwd
|
||||
$ docker exec -it -w /root mycontainer pwd
|
||||
/root
|
||||
```
|
||||
|
||||
|
||||
### Try to run `docker exec` on a paused container
|
||||
|
||||
If the container is paused, then the `docker exec` command will fail with an error:
|
||||
If the container is paused, then the `docker exec` command fails with an error:
|
||||
|
||||
```console
|
||||
$ docker pause test
|
||||
|
||||
test
|
||||
$ docker pause mycontainer
|
||||
mycontainer
|
||||
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
1ae3b36715d2 ubuntu:latest "bash" 17 seconds ago Up 16 seconds (Paused) test
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
482efdf39fac alpine "/bin/sh" 17 seconds ago Up 16 seconds (Paused) mycontainer
|
||||
|
||||
$ docker exec test ls
|
||||
$ docker exec mycontainer sh
|
||||
|
||||
FATA[0000] Error response from daemon: Container test is paused, unpause the container before exec
|
||||
Error response from daemon: Container mycontainer is paused, unpause the container before exec
|
||||
|
||||
$ echo $?
|
||||
1
|
||||
|
||||
@ -23,7 +23,7 @@ with the container. If a volume is mounted on top of an existing directory in
|
||||
the container, `docker export` will export the contents of the *underlying*
|
||||
directory, not the contents of the volume.
|
||||
|
||||
Refer to [Backup, restore, or migrate data volumes](https://docs.docker.com/storage/volumes/#backup-restore-or-migrate-data-volumes)
|
||||
Refer to [Backup, restore, or migrate data volumes](https://docs.docker.com/storage/volumes/#back-up-restore-or-migrate-data-volumes)
|
||||
in the user guide for examples on exporting data in a volume.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -47,21 +47,21 @@ c69cab00d6ef 5 months ago /bin/sh -c #(nop) MAINTAINER Lokesh Mand
|
||||
511136ea3c5a 19 months ago 0 B Imported from -
|
||||
```
|
||||
|
||||
### Format the output
|
||||
### <a name="format"></a> Format the output (--format)
|
||||
|
||||
The formatting option (`--format`) will pretty-prints history output
|
||||
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
|
||||
|
||||
@ -59,7 +59,7 @@ deleted: sha256:2c675ee9ed53425e31a13e3390bf3f539bf8637000e4bcfbb85ee03ef4d910a1
|
||||
Total reclaimed space: 16.43 MB
|
||||
```
|
||||
|
||||
### Filtering
|
||||
### <a name="filter"></a> Filtering (--filter)
|
||||
|
||||
The filtering flag (`--filter`) format is of "key=value". If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
||||
@ -103,7 +103,7 @@ $ docker images java:0
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
```
|
||||
|
||||
### List the full length image IDs
|
||||
### <a name="no-trunc"></a> List the full length image IDs (--no-trunc)
|
||||
|
||||
```console
|
||||
$ docker images --no-trunc
|
||||
@ -120,7 +120,7 @@ tryout latest sha256:2629d1fa0b81b222fca6337
|
||||
<none> <none> sha256:5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 1.089 GB
|
||||
```
|
||||
|
||||
### List image digests
|
||||
### <a name="digests"></a> List image digests (--digests)
|
||||
|
||||
Images that use the v2 or later format have a content-addressable identifier
|
||||
called a `digest`. As long as the input used to generate the image is
|
||||
@ -138,7 +138,7 @@ output includes the image digest. You can `pull` using a digest value. You can
|
||||
also reference by digest in `create`, `run`, and `rmi` commands, as well as the
|
||||
`FROM` image reference in a Dockerfile.
|
||||
|
||||
### Filtering
|
||||
### <a name="filter"></a> Filtering (--filter)
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
@ -286,22 +286,22 @@ busybox uclibc e02e811dd08f 5 weeks ago
|
||||
busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB
|
||||
```
|
||||
|
||||
### Format the output
|
||||
### <a name="format"></a> Format the output (--format)
|
||||
|
||||
The formatting option (`--format`) will pretty print container output
|
||||
using a Go template.
|
||||
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
| Placeholder | Description|
|
||||
| ---- | ---- |
|
||||
| `.ID` | Image ID |
|
||||
| `.Repository` | Image repository |
|
||||
| `.Tag` | Image tag |
|
||||
| `.Digest` | Image digest |
|
||||
| Placeholder | Description |
|
||||
|-----------------|------------------------------------------|
|
||||
| `.ID` | Image ID |
|
||||
| `.Repository` | Image repository |
|
||||
| `.Tag` | Image tag |
|
||||
| `.Digest` | Image digest |
|
||||
| `.CreatedSince` | Elapsed time since the image was created |
|
||||
| `.CreatedAt` | Time when the image was created |
|
||||
| `.Size` | Image disk size |
|
||||
| `.CreatedAt` | Time when the image was created |
|
||||
| `.Size` | Image disk size |
|
||||
|
||||
When using the `--format` option, the `image` command will either
|
||||
output the data exactly as the template declares or, when using the
|
||||
|
||||
@ -28,16 +28,15 @@ specify an archive, Docker untars it in the container relative to the `/`
|
||||
the host. To import from a remote location, specify a `URI` that begins with the
|
||||
`http://` or `https://` protocol.
|
||||
|
||||
The `--change` option will apply `Dockerfile` instructions to the image
|
||||
that is created.
|
||||
Supported `Dockerfile` instructions:
|
||||
The `--change` option applies `Dockerfile` instructions to the image that is
|
||||
created. Supported `Dockerfile` instructions:
|
||||
`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
|
||||
|
||||
## Examples
|
||||
|
||||
### Import from a remote location
|
||||
|
||||
This will create a new untagged image.
|
||||
This creates a new untagged image.
|
||||
|
||||
```console
|
||||
$ docker import https://example.com/exampleimage.tgz
|
||||
|
||||
@ -118,15 +118,15 @@ read the [`dockerd`](dockerd.md) reference page.
|
||||
|
||||
### Swarm management commands
|
||||
|
||||
| Command | Description |
|
||||
|:--------|:-------------------------------------------------------------------|
|
||||
| [swarm init](swarm_init.md) | Initialize a swarm |
|
||||
| [swarm join](swarm_join.md) | Join a swarm as a manager node or worker node |
|
||||
| [swarm leave](swarm_leave.md) | Remove the current node from the swarm |
|
||||
| [swarm join-token](swarm_join_token.md) | Display or rotate join tokens |
|
||||
| [swarm unlock](swarm_unlock.md) | Unlock swarm |
|
||||
| [swarm unlock-key](swarm_unlock_key.md) | Manage the unlock key |
|
||||
| [swarm update](swarm_update.md) | Update attributes of a swarm |
|
||||
| Command | Description |
|
||||
|:----------------------------------------|:----------------------------------------------|
|
||||
| [swarm init](swarm_init.md) | Initialize a swarm |
|
||||
| [swarm join](swarm_join.md) | Join a swarm as a manager node or worker node |
|
||||
| [swarm leave](swarm_leave.md) | Remove the current node from the swarm |
|
||||
| [swarm join-token](swarm_join-token.md) | Display or rotate join tokens |
|
||||
| [swarm unlock](swarm_unlock.md) | Unlock swarm |
|
||||
| [swarm unlock-key](swarm_unlock-key.md) | Manage the unlock key |
|
||||
| [swarm update](swarm_update.md) | Update attributes of a swarm |
|
||||
|
||||
### Swarm service commands
|
||||
|
||||
|
||||
@ -40,9 +40,9 @@ available on the volume where `/var/lib/docker` is mounted.
|
||||
|
||||
### Show output
|
||||
|
||||
The example below shows the output for a daemon running on Red Hat Enterprise Linux,
|
||||
using the `devicemapper` storage driver. As can be seen in the output, additional
|
||||
information about the `devicemapper` storage driver is shown:
|
||||
The example below shows the output for a daemon running on Ubuntu Linux,
|
||||
using the `overlay2` storage driver. As can be seen in the output, additional
|
||||
information about the `overlay2` storage driver is shown:
|
||||
|
||||
```console
|
||||
$ docker info
|
||||
@ -50,6 +50,16 @@ $ docker info
|
||||
Client:
|
||||
Context: default
|
||||
Debug Mode: false
|
||||
Plugins:
|
||||
buildx: Docker Buildx (Docker Inc.)
|
||||
Version: v0.8.2
|
||||
Path: /usr/libexec/docker/cli-plugins/docker-buildx
|
||||
compose: Docker Compose (Docker Inc.)
|
||||
Version: v2.6.0
|
||||
Path: /usr/libexec/docker/cli-plugins/docker-compose
|
||||
scan: Docker Scan (Docker Inc.)
|
||||
Version: v0.17.0
|
||||
Path: /usr/libexec/docker/cli-plugins/docker-scan
|
||||
|
||||
Server:
|
||||
Containers: 14
|
||||
@ -57,142 +67,52 @@ Server:
|
||||
Paused: 1
|
||||
Stopped: 10
|
||||
Images: 52
|
||||
Server Version: 1.10.3
|
||||
Storage Driver: devicemapper
|
||||
Pool Name: docker-202:2-25583803-pool
|
||||
Pool Blocksize: 65.54 kB
|
||||
Base Device Size: 10.74 GB
|
||||
Backing Filesystem: xfs
|
||||
Data file: /dev/loop0
|
||||
Metadata file: /dev/loop1
|
||||
Data Space Used: 1.68 GB
|
||||
Data Space Total: 107.4 GB
|
||||
Data Space Available: 7.548 GB
|
||||
Metadata Space Used: 2.322 MB
|
||||
Metadata Space Total: 2.147 GB
|
||||
Metadata Space Available: 2.145 GB
|
||||
Udev Sync Supported: true
|
||||
Deferred Removal Enabled: false
|
||||
Deferred Deletion Enabled: false
|
||||
Deferred Deleted Device Count: 0
|
||||
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
|
||||
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
|
||||
Library Version: 1.02.107-RHEL7 (2015-12-01)
|
||||
Execution Driver: native-0.2
|
||||
Server Version: 22.06.0
|
||||
Storage Driver: overlay2
|
||||
Backing Filesystem: extfs
|
||||
Supports d_type: true
|
||||
Using metacopy: false
|
||||
Native Overlay Diff: true
|
||||
userxattr: false
|
||||
Logging Driver: json-file
|
||||
Cgroup Driver: systemd
|
||||
Cgroup Version: 2
|
||||
Plugins:
|
||||
Volume: local
|
||||
Network: null host bridge
|
||||
Kernel Version: 3.10.0-327.el7.x86_64
|
||||
Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
|
||||
Network: bridge host ipvlan macvlan null overlay
|
||||
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
|
||||
Swarm: inactive
|
||||
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
|
||||
Default Runtime: runc
|
||||
Init Binary: docker-init
|
||||
containerd version: 212e8b6fa2f44b9c21b2798135fc6fb7c53efc16
|
||||
runc version: v1.1.1-0-g52de29d
|
||||
init version: de40ad0
|
||||
Security Options:
|
||||
apparmor
|
||||
seccomp
|
||||
Profile: builtin
|
||||
cgroupns
|
||||
Kernel Version: 5.15.0-25-generic
|
||||
Operating System: Ubuntu 22.04 LTS
|
||||
OSType: linux
|
||||
Architecture: x86_64
|
||||
CPUs: 1
|
||||
Total Memory: 991.7 MiB
|
||||
Name: ip-172-30-0-91.ec2.internal
|
||||
ID: I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S
|
||||
ID: 4cee4408-10d2-4e17-891c-a41736ac4536
|
||||
Docker Root Dir: /var/lib/docker
|
||||
Debug Mode: false
|
||||
Username: gordontheturtle
|
||||
Registry: https://index.docker.io/v1/
|
||||
Experimental: false
|
||||
Insecure registries:
|
||||
myinsecurehost:5000
|
||||
127.0.0.0/8
|
||||
```
|
||||
|
||||
### Show debugging output
|
||||
|
||||
Here is a sample output for a daemon running on Ubuntu, using the overlay2
|
||||
storage driver and a node that is part of a 2-node swarm:
|
||||
|
||||
```console
|
||||
$ docker --debug info
|
||||
|
||||
Client:
|
||||
Context: default
|
||||
Debug Mode: true
|
||||
|
||||
Server:
|
||||
Containers: 14
|
||||
Running: 3
|
||||
Paused: 1
|
||||
Stopped: 10
|
||||
Images: 52
|
||||
Server Version: 1.13.0
|
||||
Storage Driver: overlay2
|
||||
Backing Filesystem: extfs
|
||||
Supports d_type: true
|
||||
Native Overlay Diff: false
|
||||
Logging Driver: json-file
|
||||
Cgroup Driver: cgroupfs
|
||||
Plugins:
|
||||
Volume: local
|
||||
Network: bridge host macvlan null overlay
|
||||
Swarm: active
|
||||
NodeID: rdjq45w1op418waxlairloqbm
|
||||
Is Manager: true
|
||||
ClusterID: te8kdyw33n36fqiz74bfjeixd
|
||||
Managers: 1
|
||||
Nodes: 2
|
||||
Orchestration:
|
||||
Task History Retention Limit: 5
|
||||
Raft:
|
||||
Snapshot Interval: 10000
|
||||
Number of Old Snapshots to Retain: 0
|
||||
Heartbeat Tick: 1
|
||||
Election Tick: 3
|
||||
Dispatcher:
|
||||
Heartbeat Period: 5 seconds
|
||||
CA Configuration:
|
||||
Expiry Duration: 3 months
|
||||
Root Rotation In Progress: false
|
||||
Node Address: 172.16.66.128 172.16.66.129
|
||||
Manager Addresses:
|
||||
172.16.66.128:2477
|
||||
Runtimes: runc
|
||||
Default Runtime: runc
|
||||
Init Binary: docker-init
|
||||
containerd version: 8517738ba4b82aff5662c97ca4627e7e4d03b531
|
||||
runc version: ac031b5bf1cc92239461125f4c1ffb760522bbf2
|
||||
init version: N/A (expected: v0.13.0)
|
||||
Security Options:
|
||||
apparmor
|
||||
seccomp
|
||||
Profile: default
|
||||
Kernel Version: 4.4.0-31-generic
|
||||
Operating System: Ubuntu 16.04.1 LTS
|
||||
OSType: linux
|
||||
Architecture: x86_64
|
||||
CPUs: 2
|
||||
Total Memory: 1.937 GiB
|
||||
Name: ubuntu
|
||||
ID: H52R:7ZR6:EIIA:76JG:ORIY:BVKF:GSFU:HNPG:B5MK:APSC:SZ3Q:N326
|
||||
Docker Root Dir: /var/lib/docker
|
||||
Debug Mode: true
|
||||
File Descriptors: 30
|
||||
Goroutines: 123
|
||||
System Time: 2016-11-12T17:24:37.955404361-08:00
|
||||
EventsListeners: 0
|
||||
Http Proxy: http://test:test@proxy.example.com:8080
|
||||
Https Proxy: https://test:test@proxy.example.com:8080
|
||||
No Proxy: localhost,127.0.0.1,docker-registry.somecorporation.com
|
||||
Registry: https://index.docker.io/v1/
|
||||
WARNING: No swap limit support
|
||||
Labels:
|
||||
storage=ssd
|
||||
staging=true
|
||||
Experimental: false
|
||||
Insecure Registries:
|
||||
127.0.0.0/8
|
||||
Registry Mirrors:
|
||||
http://192.168.1.2/
|
||||
http://registry-mirror.example.com:5000/
|
||||
Live Restore Enabled: false
|
||||
```
|
||||
|
||||
The global `-D` option causes all `docker` commands to output debug information.
|
||||
|
||||
### Format the output
|
||||
### <a name="format"></a> Format the output (--format)
|
||||
|
||||
You can also specify the output format:
|
||||
|
||||
@ -204,13 +124,18 @@ $ docker info --format '{{json .}}'
|
||||
|
||||
### Run `docker info` on Windows
|
||||
|
||||
Here is a sample output for a daemon running on Windows Server 2016:
|
||||
Here is a sample output for a daemon running on Windows Server:
|
||||
|
||||
```console
|
||||
E:\docker>docker info
|
||||
C:\> docker info
|
||||
|
||||
Client:
|
||||
Context: default
|
||||
Debug Mode: false
|
||||
Plugins:
|
||||
buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
|
||||
compose: Docker Compose (Docker Inc., v2.6.0)
|
||||
scan: Docker Scan (Docker Inc., v0.17.0)
|
||||
|
||||
Server:
|
||||
Containers: 1
|
||||
@ -218,27 +143,29 @@ Server:
|
||||
Paused: 0
|
||||
Stopped: 1
|
||||
Images: 17
|
||||
Server Version: 1.13.0
|
||||
Server Version: 20.10.16
|
||||
Storage Driver: windowsfilter
|
||||
Windows:
|
||||
Logging Driver: json-file
|
||||
Plugins:
|
||||
Volume: local
|
||||
Network: nat null overlay
|
||||
Network: ics internal l2bridge l2tunnel nat null overlay private transparent
|
||||
Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
|
||||
Swarm: inactive
|
||||
Default Isolation: process
|
||||
Kernel Version: 10.0 14393 (14393.206.amd64fre.rs1_release.160912-1937)
|
||||
Operating System: Windows Server 2016 Datacenter
|
||||
Kernel Version: 10.0 20348 (20348.1.amd64fre.fe_release.210507-1500)
|
||||
Operating System: Microsoft Windows Server Version 21H2 (OS Build 20348.707)
|
||||
OSType: windows
|
||||
Architecture: x86_64
|
||||
CPUs: 8
|
||||
Total Memory: 3.999 GiB
|
||||
Name: WIN-V0V70C0LU5P
|
||||
ID: NYMS:B5VK:UMSL:FVDZ:EWB5:FKVK:LPFL:FJMQ:H6FT:BZJ6:L2TD:XH62
|
||||
Docker Root Dir: C:\control
|
||||
ID: 2880d38d-464e-4d01-91bd-c76f33ba3981
|
||||
Docker Root Dir: C:\ProgramData\docker
|
||||
Debug Mode: false
|
||||
Registry: https://index.docker.io/v1/
|
||||
Experimental: true
|
||||
Insecure Registries:
|
||||
myregistry:5000
|
||||
127.0.0.0/8
|
||||
Registry Mirrors:
|
||||
http://192.168.1.2/
|
||||
|
||||
@ -25,19 +25,19 @@ Docker inspect provides detailed information on constructs controlled by Docker.
|
||||
|
||||
By default, `docker inspect` will render results in a JSON array.
|
||||
|
||||
## Request a custom response format (--format)
|
||||
### <a name="format"></a> Format the output (--format)
|
||||
|
||||
If a format is specified, the given template will be executed for each result.
|
||||
|
||||
Go's [text/template](https://golang.org/pkg/text/template/) package
|
||||
describes all the details of the format.
|
||||
Go's [text/template](https://golang.org/pkg/text/template/) package describes
|
||||
all the details of the format.
|
||||
|
||||
## Specify target type (--type)
|
||||
### <a name="type"></a> Specify target type (--type)
|
||||
|
||||
`--type container|image|node|network|secret|service|volume|task|plugin`
|
||||
|
||||
The `docker inspect` command matches any type of object by either ID or name.
|
||||
In some cases multiple type of objects (for example, a container and a volume)
|
||||
The `docker inspect` command matches any type of object by either ID or name. In
|
||||
some cases multiple type of objects (for example, a container and a volume)
|
||||
exist with the same name, making the result ambiguous.
|
||||
|
||||
To restrict `docker inspect` to a specific type of object, use the `--type`
|
||||
@ -49,6 +49,35 @@ The following example inspects a _volume_ named "myvolume"
|
||||
$ docker inspect --type=volume myvolume
|
||||
```
|
||||
|
||||
### <a name="size"></a> Inspect the size of a container (-s, --size)
|
||||
|
||||
The `--size`, or short-form `-s`, option adds two additional fields to the
|
||||
`docker inspect` output. This option only works for containers. The container
|
||||
doesn't have to be running, it also works for stopped containers.
|
||||
|
||||
```console
|
||||
$ docker inspect --size mycontainer
|
||||
```
|
||||
|
||||
The output includes the full output of a regular `docker inspect` command, with
|
||||
the following additional fields:
|
||||
|
||||
- `SizeRootFs`: the total size of all the files in the container, in bytes.
|
||||
- `SizeRw`: the size of the files that have been created or changed in the
|
||||
container, compared to it's image, in bytes.
|
||||
|
||||
```console
|
||||
$ docker run --name database -d redis
|
||||
3b2cbf074c99db4a0cad35966a9e24d7bc277f5565c17233386589029b7db273
|
||||
$ docker inspect --size database -f '{{ .SizeRootFs }}'
|
||||
123125760
|
||||
$ docker inspect --size database -f '{{ .SizeRw }}'
|
||||
8192
|
||||
$ docker exec database fallocate -l 1000 /newfile
|
||||
$ docker inspect --size database -f '{{ .SizeRw }}'
|
||||
12288
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Get an instance's IP address
|
||||
@ -80,8 +109,7 @@ $ docker inspect --format='{{.Config.Image}}' $INSTANCE_ID
|
||||
|
||||
### List all port bindings
|
||||
|
||||
You can loop over arrays and maps in the results to produce simple text
|
||||
output:
|
||||
You can loop over arrays and maps in the results to produce simple text output:
|
||||
|
||||
```console
|
||||
$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
|
||||
@ -89,13 +117,12 @@ $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}}
|
||||
|
||||
### Find a specific port mapping
|
||||
|
||||
The `.Field` syntax doesn't work when the field name begins with a
|
||||
number, but the template language's `index` function does. The
|
||||
`.NetworkSettings.Ports` section contains a map of the internal port
|
||||
mappings to a list of external address/port objects. To grab just the
|
||||
numeric public port, you use `index` to find the specific port map, and
|
||||
then `index` 0 contains the first object inside of that. Then we ask for
|
||||
the `HostPort` field to get the public address.
|
||||
The `.Field` syntax doesn't work when the field name begins with a number, but
|
||||
the template language's `index` function does. The `.NetworkSettings.Ports`
|
||||
section contains a map of the internal port mappings to a list of external
|
||||
address/port objects. To grab just the numeric public port, you use `index` to
|
||||
find the specific port map, and then `index` 0 contains the first object inside
|
||||
of that. Then we ask for the `HostPort` field to get the public address.
|
||||
|
||||
```console
|
||||
$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
|
||||
@ -103,10 +130,9 @@ $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0)
|
||||
|
||||
### Get a subsection in JSON format
|
||||
|
||||
If you request a field which is itself a structure containing other
|
||||
fields, by default you get a Go-style dump of the inner values.
|
||||
Docker adds a template function, `json`, which can be applied to get
|
||||
results in JSON format.
|
||||
If you request a field which is itself a structure containing other fields, by
|
||||
default you get a Go-style dump of the inner values. Docker adds a template
|
||||
function, `json`, which can be applied to get results in JSON format.
|
||||
|
||||
```console
|
||||
$ docker inspect --format='{{json .Config}}' $INSTANCE_ID
|
||||
|
||||
@ -51,7 +51,7 @@ The following example sends the default `SIGKILL` signal to the container named
|
||||
$ docker kill my_container
|
||||
```
|
||||
|
||||
### Send a custom signal to a container
|
||||
### <a name="signal"></a> Send a custom signal to a container (--signal)
|
||||
|
||||
The following example sends a `SIGHUP` signal to the container named
|
||||
`my_container`:
|
||||
|
||||
@ -30,18 +30,25 @@ bzip2, or xz) from a file or STDIN. It restores both images and tags.
|
||||
$ docker image ls
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
```
|
||||
|
||||
### Load images from STDIN
|
||||
|
||||
```console
|
||||
$ docker load < busybox.tar.gz
|
||||
|
||||
Loaded image: busybox:latest
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
busybox latest 769b9341d937 7 weeks ago 2.489 MB
|
||||
```
|
||||
|
||||
### <a name="input"></a> Load images from a file (--input)
|
||||
|
||||
```console
|
||||
$ docker load --input fedora.tar
|
||||
|
||||
Loaded image: fedora:rawhide
|
||||
|
||||
Loaded image: fedora:20
|
||||
|
||||
$ docker images
|
||||
|
||||
@ -34,7 +34,7 @@ adding the server name.
|
||||
$ docker login localhost:8080
|
||||
```
|
||||
|
||||
### Provide a password using STDIN
|
||||
### <a name="password-stdin"></a> Provide a password using STDIN (--password-stdin)
|
||||
|
||||
To run the `docker login` command non-interactively, you can set the
|
||||
`--password-stdin` flag to provide a password through `STDIN`. Using
|
||||
|
||||
@ -25,11 +25,6 @@ Options:
|
||||
|
||||
The `docker logs` command batch-retrieves logs present at the time of execution.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> This command is only functional for containers that are started with the
|
||||
> `json-file` or `journald` logging driver.
|
||||
|
||||
For more information about selecting and configuring logging drivers, refer to
|
||||
[Configure logging drivers](https://docs.docker.com/config/containers/logging/configure/).
|
||||
|
||||
@ -63,7 +58,7 @@ fraction of a second no more than nine digits long. You can combine the
|
||||
|
||||
## Examples
|
||||
|
||||
### Retrieve logs until a specific point in time
|
||||
### <a name="until"></a> Retrieve logs until a specific point in time (--until)
|
||||
|
||||
In order to retrieve logs before a specific point in time, run:
|
||||
|
||||
|
||||
@ -36,13 +36,14 @@ $ docker network connect multi-host-network container1
|
||||
|
||||
### Connect a container to a network when it starts
|
||||
|
||||
You can also use the `docker run --network=<network-name>` option to start a container and immediately connect it to a network.
|
||||
You can also use the `docker run --network=<network-name>` option to start a
|
||||
container and immediately connect it to a network.
|
||||
|
||||
```console
|
||||
$ docker run -itd --network=multi-host-network busybox
|
||||
```
|
||||
|
||||
### Specify the IP address a container will use on a given network
|
||||
### <a name="ip"></a> Specify the IP address a container will use on a given network (--ip)
|
||||
|
||||
You can specify the IP address you want to be assigned to the container's interface.
|
||||
|
||||
@ -50,7 +51,7 @@ You can specify the IP address you want to be assigned to the container's interf
|
||||
$ docker network connect --ip 10.10.36.122 multi-host-network container2
|
||||
```
|
||||
|
||||
### Use the legacy `--link` option
|
||||
### <a name="link"></a> Use the legacy `--link` option (--link)
|
||||
|
||||
You can use `--link` option to link another container with a preferred alias
|
||||
|
||||
@ -58,7 +59,7 @@ You can use `--link` option to link another container with a preferred alias
|
||||
$ docker network connect --link container1:c1 multi-host-network container2
|
||||
```
|
||||
|
||||
### Create a network alias for a container
|
||||
### <a name="alias"></a> Create a network alias for a container (--alias)
|
||||
|
||||
`--alias` option can be used to resolve the container by another name in the network
|
||||
being connected to.
|
||||
@ -87,14 +88,17 @@ $ docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 multi-
|
||||
$ docker network connect --ip 172.20.128.2 multi-host-network container2
|
||||
```
|
||||
|
||||
To verify the container is connected, use the `docker network inspect` command. Use `docker network disconnect` to remove a container from the network.
|
||||
To verify the container is connected, use the `docker network inspect` command.
|
||||
Use `docker network disconnect` to remove a container from the network.
|
||||
|
||||
Once connected in network, containers can communicate using only another
|
||||
container's IP address or name. For `overlay` networks or custom plugins that
|
||||
support multi-host connectivity, containers connected to the same multi-host
|
||||
network but launched from different Engines can also communicate in this way.
|
||||
|
||||
You can connect a container to one or more networks. The networks need not be the same type. For example, you can connect a single container bridge and overlay networks.
|
||||
You can connect a container to one or more networks. The networks need not be
|
||||
the same type. For example, you can connect a single container bridge and overlay
|
||||
networks.
|
||||
|
||||
## Related commands
|
||||
|
||||
|
||||
@ -184,7 +184,7 @@ network driver, again with their approximate equivalents to `docker daemon`.
|
||||
|--------------|----------------|--------------------------------------------|
|
||||
| `--gateway` | - | IPv4 or IPv6 Gateway for the master subnet |
|
||||
| `--ip-range` | `--fixed-cidr` | Allocate IPs from a range |
|
||||
| `--internal` | - | Restrict external access to the network |
|
||||
| `--internal` | - | Restrict external access to the network |
|
||||
| `--ipv6` | `--ipv6` | Enable IPv6 networking |
|
||||
| `--subnet` | `--bip` | Subnet for network |
|
||||
|
||||
@ -197,14 +197,14 @@ $ docker network create \
|
||||
simple-network
|
||||
```
|
||||
|
||||
### Network internal mode
|
||||
### <a name="internal"></a> Network internal mode (--internal)
|
||||
|
||||
By default, when you connect a container to an `overlay` network, Docker also
|
||||
connects a bridge network to it to provide external connectivity. If you want
|
||||
to create an externally isolated `overlay` network, you can specify the
|
||||
`--internal` option.
|
||||
|
||||
### Network ingress mode
|
||||
### <a name="ingress"></a> Network ingress mode (--ingress)
|
||||
|
||||
You can create the network which will be used to provide the routing-mesh in the
|
||||
swarm cluster. You do so by specifying `--ingress` when creating the network. Only
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user