This flag has been deprecated in version below 1.10 so it's safe to
remove now, according to our deprecation policy.
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
... | ... |
@@ -1,7 +1,6 @@ |
1 | 1 |
package container |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "encoding/json" |
|
5 | 4 |
"fmt" |
6 | 5 |
|
7 | 6 |
"golang.org/x/net/context" |
... | ... |
@@ -10,7 +9,6 @@ import ( |
10 | 10 |
"github.com/docker/docker/cli" |
11 | 11 |
dockeropts "github.com/docker/docker/opts" |
12 | 12 |
"github.com/docker/engine-api/types" |
13 |
- containertypes "github.com/docker/engine-api/types/container" |
|
14 | 13 |
"github.com/spf13/cobra" |
15 | 14 |
) |
16 | 15 |
|
... | ... |
@@ -22,7 +20,6 @@ type commitOptions struct { |
22 | 22 |
comment string |
23 | 23 |
author string |
24 | 24 |
changes dockeropts.ListOpts |
25 |
- config string |
|
26 | 25 |
} |
27 | 26 |
|
28 | 27 |
// NewCommitCommand creates a new cobra.Command for `docker commit` |
... | ... |
@@ -53,10 +50,6 @@ func NewCommitCommand(dockerCli *client.DockerCli) *cobra.Command { |
53 | 53 |
opts.changes = dockeropts.NewListOpts(nil) |
54 | 54 |
flags.VarP(&opts.changes, "change", "c", "Apply Dockerfile instruction to the created image") |
55 | 55 |
|
56 |
- // FIXME: --run is deprecated, it will be replaced with inline Dockerfile commands. |
|
57 |
- flags.StringVar(&opts.config, "run", "", "This option is deprecated and will be removed in a future version in favor of inline Dockerfile-compatible commands") |
|
58 |
- flags.MarkDeprecated("run", "it will be replaced with inline Dockerfile commands.") |
|
59 |
- |
|
60 | 56 |
return cmd |
61 | 57 |
} |
62 | 58 |
|
... | ... |
@@ -66,21 +59,12 @@ func runCommit(dockerCli *client.DockerCli, opts *commitOptions) error { |
66 | 66 |
name := opts.container |
67 | 67 |
reference := opts.reference |
68 | 68 |
|
69 |
- var config *containertypes.Config |
|
70 |
- if opts.config != "" { |
|
71 |
- config = &containertypes.Config{} |
|
72 |
- if err := json.Unmarshal([]byte(opts.config), config); err != nil { |
|
73 |
- return err |
|
74 |
- } |
|
75 |
- } |
|
76 |
- |
|
77 | 69 |
options := types.ContainerCommitOptions{ |
78 | 70 |
Reference: reference, |
79 | 71 |
Comment: opts.comment, |
80 | 72 |
Author: opts.author, |
81 | 73 |
Changes: opts.changes.GetAll(), |
82 | 74 |
Pause: opts.pause, |
83 |
- Config: config, |
|
84 | 75 |
} |
85 | 76 |
|
86 | 77 |
response, err := dockerCli.Client().ContainerCommit(ctx, name, options) |
... | ... |
@@ -172,6 +172,15 @@ The single-dash (`-help`) was removed, in favor of the double-dash `--help` |
172 | 172 |
docker -help |
173 | 173 |
docker [COMMAND] -help |
174 | 174 |
|
175 |
+### `--run` flag on docker commit |
|
176 |
+ |
|
177 |
+**Deprecated In Release: [v0.10.0](https://github.com/docker/docker/releases/tag/v0.10.0)** |
|
178 |
+ |
|
179 |
+**Removed In Release: [v1.13.0](https://github.com/docker/docker/releases/)** |
|
180 |
+ |
|
181 |
+The flag `--run` of the docker commit (and its short version `-run`) were deprecated in favor |
|
182 |
+of the `--changes` flag that allows to pass `Dockerfile` commands. |
|
183 |
+ |
|
175 | 184 |
|
176 | 185 |
### Interacting with V1 registries |
177 | 186 |
|
... | ... |
@@ -186,3 +195,4 @@ Since 1.9, Docker Content Trust Offline key has been renamed to Root key and the |
186 | 186 |
|
187 | 187 |
- DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE is now named DOCKER_CONTENT_TRUST_ROOT_PASSPHRASE |
188 | 188 |
- DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE is now named DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE |
189 |
+ |
... | ... |
@@ -438,72 +438,6 @@ func (s *DockerSuite) TestBuildEnvOverwrite(c *check.C) { |
438 | 438 |
|
439 | 439 |
} |
440 | 440 |
|
441 |
-func (s *DockerSuite) TestBuildOnBuildForbiddenMaintainerInSourceImage(c *check.C) { |
|
442 |
- name := "testbuildonbuildforbiddenmaintainerinsourceimage" |
|
443 |
- |
|
444 |
- out, _ := dockerCmd(c, "create", "busybox", "true") |
|
445 |
- |
|
446 |
- cleanedContainerID := strings.TrimSpace(out) |
|
447 |
- |
|
448 |
- dockerCmd(c, "commit", "--run", "{\"OnBuild\":[\"MAINTAINER docker.io\"]}", cleanedContainerID, "onbuild") |
|
449 |
- |
|
450 |
- _, err := buildImage(name, |
|
451 |
- `FROM onbuild`, |
|
452 |
- true) |
|
453 |
- if err != nil { |
|
454 |
- if !strings.Contains(err.Error(), "maintainer isn't allowed as an ONBUILD trigger") { |
|
455 |
- c.Fatalf("Wrong error %v, must be about MAINTAINER and ONBUILD in source image", err) |
|
456 |
- } |
|
457 |
- } else { |
|
458 |
- c.Fatal("Error must not be nil") |
|
459 |
- } |
|
460 |
- |
|
461 |
-} |
|
462 |
- |
|
463 |
-func (s *DockerSuite) TestBuildOnBuildForbiddenFromInSourceImage(c *check.C) { |
|
464 |
- name := "testbuildonbuildforbiddenfrominsourceimage" |
|
465 |
- |
|
466 |
- out, _ := dockerCmd(c, "create", "busybox", "true") |
|
467 |
- |
|
468 |
- cleanedContainerID := strings.TrimSpace(out) |
|
469 |
- |
|
470 |
- dockerCmd(c, "commit", "--run", "{\"OnBuild\":[\"FROM busybox\"]}", cleanedContainerID, "onbuild") |
|
471 |
- |
|
472 |
- _, err := buildImage(name, |
|
473 |
- `FROM onbuild`, |
|
474 |
- true) |
|
475 |
- if err != nil { |
|
476 |
- if !strings.Contains(err.Error(), "from isn't allowed as an ONBUILD trigger") { |
|
477 |
- c.Fatalf("Wrong error %v, must be about FROM and ONBUILD in source image", err) |
|
478 |
- } |
|
479 |
- } else { |
|
480 |
- c.Fatal("Error must not be nil") |
|
481 |
- } |
|
482 |
- |
|
483 |
-} |
|
484 |
- |
|
485 |
-func (s *DockerSuite) TestBuildOnBuildForbiddenChainedInSourceImage(c *check.C) { |
|
486 |
- name := "testbuildonbuildforbiddenchainedinsourceimage" |
|
487 |
- |
|
488 |
- out, _ := dockerCmd(c, "create", "busybox", "true") |
|
489 |
- |
|
490 |
- cleanedContainerID := strings.TrimSpace(out) |
|
491 |
- |
|
492 |
- dockerCmd(c, "commit", "--run", "{\"OnBuild\":[\"ONBUILD RUN ls\"]}", cleanedContainerID, "onbuild") |
|
493 |
- |
|
494 |
- _, err := buildImage(name, |
|
495 |
- `FROM onbuild`, |
|
496 |
- true) |
|
497 |
- if err != nil { |
|
498 |
- if !strings.Contains(err.Error(), "Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed") { |
|
499 |
- c.Fatalf("Wrong error %v, must be about chaining ONBUILD in source image", err) |
|
500 |
- } |
|
501 |
- } else { |
|
502 |
- c.Fatal("Error must not be nil") |
|
503 |
- } |
|
504 |
- |
|
505 |
-} |
|
506 |
- |
|
507 | 441 |
func (s *DockerSuite) TestBuildOnBuildCmdEntrypointJSON(c *check.C) { |
508 | 442 |
name1 := "onbuildcmd" |
509 | 443 |
name2 := "onbuildgenerated" |
... | ... |
@@ -144,46 +144,3 @@ func (s *DockerSuite) TestCommitChange(c *check.C) { |
144 | 144 |
} |
145 | 145 |
} |
146 | 146 |
} |
147 |
- |
|
148 |
-// TODO: commit --run is deprecated, remove this once --run is removed |
|
149 |
-func (s *DockerSuite) TestCommitMergeConfigRun(c *check.C) { |
|
150 |
- testRequires(c, DaemonIsLinux) |
|
151 |
- name := "commit-test" |
|
152 |
- out, _ := dockerCmd(c, "run", "-d", "-e=FOO=bar", "busybox", "/bin/sh", "-c", "echo testing > /tmp/foo") |
|
153 |
- id := strings.TrimSpace(out) |
|
154 |
- |
|
155 |
- dockerCmd(c, "commit", `--run={"Cmd": ["cat", "/tmp/foo"]}`, id, "commit-test") |
|
156 |
- |
|
157 |
- out, _ = dockerCmd(c, "run", "--name", name, "commit-test") |
|
158 |
- //run config in committed container was not merged |
|
159 |
- c.Assert(strings.TrimSpace(out), checker.Equals, "testing") |
|
160 |
- |
|
161 |
- type cfg struct { |
|
162 |
- Env []string |
|
163 |
- Cmd []string |
|
164 |
- } |
|
165 |
- config1 := cfg{} |
|
166 |
- inspectFieldAndMarshall(c, id, "Config", &config1) |
|
167 |
- |
|
168 |
- config2 := cfg{} |
|
169 |
- inspectFieldAndMarshall(c, name, "Config", &config2) |
|
170 |
- |
|
171 |
- // Env has at least PATH loaded as well here, so let's just grab the FOO one |
|
172 |
- var env1, env2 string |
|
173 |
- for _, e := range config1.Env { |
|
174 |
- if strings.HasPrefix(e, "FOO") { |
|
175 |
- env1 = e |
|
176 |
- break |
|
177 |
- } |
|
178 |
- } |
|
179 |
- for _, e := range config2.Env { |
|
180 |
- if strings.HasPrefix(e, "FOO") { |
|
181 |
- env2 = e |
|
182 |
- break |
|
183 |
- } |
|
184 |
- } |
|
185 |
- |
|
186 |
- if len(config1.Env) != len(config2.Env) || env1 != env2 && env2 != "" { |
|
187 |
- c.Fatalf("expected envs to match: %v - %v", config1.Env, config2.Env) |
|
188 |
- } |
|
189 |
-} |