Skip to content

Commit e241f53

Browse files
authored
Merge pull request #6460 from thaJeztah/no_pause
deprecate "--pause" flag on docker commit in favor of "--no-pause"
2 parents 2333226 + 3c244d1 commit e241f53

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

cli/command/container/commit.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package container
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67

78
"github.com/docker/cli/cli"
@@ -17,6 +18,7 @@ type commitOptions struct {
1718
reference string
1819

1920
pause bool
21+
noPause bool
2022
comment string
2123
author string
2224
changes opts.ListOpts
@@ -35,6 +37,12 @@ func newCommitCommand(dockerCLI command.Cli) *cobra.Command {
3537
if len(args) > 1 {
3638
options.reference = args[1]
3739
}
40+
if cmd.Flag("pause").Changed {
41+
if cmd.Flag("no-pause").Changed {
42+
return errors.New("conflicting options: --no-pause and --pause cannot be used together")
43+
}
44+
options.noPause = !options.pause
45+
}
3846
return runCommit(cmd.Context(), dockerCLI, &options)
3947
},
4048
Annotations: map[string]string{
@@ -47,7 +55,11 @@ func newCommitCommand(dockerCLI command.Cli) *cobra.Command {
4755
flags := cmd.Flags()
4856
flags.SetInterspersed(false)
4957

50-
flags.BoolVarP(&options.pause, "pause", "p", true, "Pause container during commit")
58+
// TODO(thaJeztah): Deprecated: the --pause flag was deprecated in v29 and can be removed in v30.
59+
flags.BoolVarP(&options.pause, "pause", "p", true, "Pause container during commit (deprecated: use --no-pause instead)")
60+
_ = flags.MarkDeprecated("pause", "and enabled by default. Use --no-pause to disable pausing during commit.")
61+
62+
flags.BoolVar(&options.noPause, "no-pause", false, "Disable pausing container during commit")
5163
flags.StringVarP(&options.comment, "message", "m", "", "Commit message")
5264
flags.StringVarP(&options.author, "author", "a", "", `Author (e.g., "John Hannibal Smith <[email protected]>")`)
5365

@@ -63,12 +75,12 @@ func runCommit(ctx context.Context, dockerCli command.Cli, options *commitOption
6375
Comment: options.comment,
6476
Author: options.author,
6577
Changes: options.changes.GetSlice(),
66-
Pause: options.pause,
78+
Pause: !options.noPause,
6779
})
6880
if err != nil {
6981
return err
7082
}
7183

72-
fmt.Fprintln(dockerCli.Out(), response.ID)
84+
_, _ = fmt.Fprintln(dockerCli.Out(), response.ID)
7385
return nil
7486
}

cli/command/container/commit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestRunCommit(t *testing.T) {
3737
"--author", "Author Name <[email protected]>",
3838
"--change", "EXPOSE 80",
3939
"--message", "commit message",
40-
"--pause=false",
40+
"--no-pause",
4141
"container-id",
4242
},
4343
)

docs/deprecated.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ The following table provides an overview of the current status of deprecated fea
5353

5454
| Status | Feature | Deprecated | Remove |
5555
|------------|------------------------------------------------------------------------------------------------------------------------------------|------------|--------|
56+
| Deprecated | [`--pause` option on `docker commit`](#--pause-option-on-docker-commit) | v29.0 | v30.0 |
5657
| Deprecated | [Legacy links environment variables](#legacy-links-environment-variables) | v28.4 | v30.0 |
5758
| Deprecated | [Special handling for quoted values for TLS flags](#special-handling-for-quoted-values-for-tls-flags) | v28.4 | v29.0 |
5859
| Deprecated | [Empty/nil fields in image Config from inspect API](#emptynil-fields-in-image-config-from-inspect-api) | v28.3 | v29.0 |
@@ -124,6 +125,19 @@ The following table provides an overview of the current status of deprecated fea
124125
| Removed | [`--run` flag on `docker commit`](#--run-flag-on-docker-commit) | v0.10 | v1.13 |
125126
| Removed | [Three arguments form in `docker import`](#three-arguments-form-in-docker-import) | v0.6.7 | v1.12 |
126127

128+
### `--pause` option on `docker commit`
129+
130+
**Deprecated in release: v29.0**
131+
132+
**Target for removal in release: v30.0**
133+
134+
The `--pause` option is enabled by default since Docker v1.1.0 to prevent
135+
committing containers in an inconsistent state, but can be disabled by
136+
setting the `--pause=false` option. In docker CLI v29.0 this flag is
137+
replaced by a `--no-pause` flag instead. The `--pause` option is still
138+
functional in the v29.0 release, printing a deprecation warning, but
139+
will be removed in docker CLI v30.
140+
127141
### Legacy links environment variables
128142

129143
**Deprecated in release: v28.4**

docs/reference/commandline/commit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Create a new image from a container's changes
1414
| `-a`, `--author` | `string` | | Author (e.g., `John Hannibal Smith <[email protected]>`) |
1515
| `-c`, `--change` | `list` | | Apply Dockerfile instruction to the created image |
1616
| `-m`, `--message` | `string` | | Commit message |
17-
| `-p`, `--pause` | `bool` | `true` | Pause container during commit |
17+
| `--no-pause` | `bool` | | Disable pausing container during commit |
1818

1919

2020
<!---MARKER_GEN_END-->

docs/reference/commandline/container_commit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Create a new image from a container's changes
1414
| `-a`, `--author` | `string` | | Author (e.g., `John Hannibal Smith <[email protected]>`) |
1515
| [`-c`](#change), [`--change`](#change) | `list` | | Apply Dockerfile instruction to the created image |
1616
| `-m`, `--message` | `string` | | Commit message |
17-
| `-p`, `--pause` | `bool` | `true` | Pause container during commit |
17+
| `--no-pause` | `bool` | | Disable pausing container during commit |
1818

1919

2020
<!---MARKER_GEN_END-->

0 commit comments

Comments
 (0)