Browse code

client: ContainerCommitOptions: change "Pause" to "NoPause"

Commit [moby@17d870b] (API v1.13, docker v1.1.0) changed the default to pause
containers during commit, keeping the behavior opt-in for older API versions.
This version-gate was removed in [moby@1b1147e] because API versions lower
than v1.23 were no longer supported.

However, the client still required opting-in to pausing containers, which
is handled by setting the `Pause` field to true by default. This patch changes
the client option to reflect the default; after this change, we should also
consider changing the API make disabling pause a more explicit option, and
to change the "pause" argument to a "no-pause".

[moby@17d870b]: https://github.com/moby/moby/commit/17d870bed5ef997c30da1e8b9843f4e84202f8d4
[moby@1b1147e]: https://github.com/moby/moby/commit/1b1147e46b732caeaed4ae365cd56ccbfdf40233

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/09/22 19:18:55
Showing 3 changed files
... ...
@@ -16,7 +16,7 @@ type ContainerCommitOptions struct {
16 16
 	Comment   string
17 17
 	Author    string
18 18
 	Changes   []string
19
-	Pause     bool
19
+	NoPause   bool // NoPause disables pausing the container during commit.
20 20
 	Config    *container.Config
21 21
 }
22 22
 
... ...
@@ -54,7 +54,7 @@ func (cli *Client) ContainerCommit(ctx context.Context, containerID string, opti
54 54
 	for _, change := range options.Changes {
55 55
 		query.Add("changes", change)
56 56
 	}
57
-	if !options.Pause {
57
+	if options.NoPause {
58 58
 		query.Set("pause", "0")
59 59
 	}
60 60
 
... ...
@@ -98,7 +98,7 @@ func TestContainerCommit(t *testing.T) {
98 98
 		Comment:   expectedComment,
99 99
 		Author:    expectedAuthor,
100 100
 		Changes:   expectedChanges,
101
-		Pause:     false,
101
+		NoPause:   true,
102 102
 	})
103 103
 	assert.NilError(t, err)
104 104
 	assert.Check(t, is.Equal(r.ID, "new_container_id"))
... ...
@@ -16,7 +16,7 @@ type ContainerCommitOptions struct {
16 16
 	Comment   string
17 17
 	Author    string
18 18
 	Changes   []string
19
-	Pause     bool
19
+	NoPause   bool // NoPause disables pausing the container during commit.
20 20
 	Config    *container.Config
21 21
 }
22 22
 
... ...
@@ -54,7 +54,7 @@ func (cli *Client) ContainerCommit(ctx context.Context, containerID string, opti
54 54
 	for _, change := range options.Changes {
55 55
 		query.Add("changes", change)
56 56
 	}
57
-	if !options.Pause {
57
+	if options.NoPause {
58 58
 		query.Set("pause", "0")
59 59
 	}
60 60