diff --git a/api/client/container/commit.go b/api/client/container/commit.go index 9c6525898e..eb23b168d7 100644 --- a/api/client/container/commit.go +++ b/api/client/container/commit.go @@ -1,7 +1,6 @@ package container import ( - "encoding/json" "fmt" "golang.org/x/net/context" @@ -10,7 +9,6 @@ import ( "github.com/docker/docker/cli" dockeropts "github.com/docker/docker/opts" "github.com/docker/engine-api/types" - containertypes "github.com/docker/engine-api/types/container" "github.com/spf13/cobra" ) @@ -22,7 +20,6 @@ type commitOptions struct { comment string author string changes dockeropts.ListOpts - config string } // NewCommitCommand creates a new cobra.Command for `docker commit` @@ -53,10 +50,6 @@ func NewCommitCommand(dockerCli *client.DockerCli) *cobra.Command { opts.changes = dockeropts.NewListOpts(nil) flags.VarP(&opts.changes, "change", "c", "Apply Dockerfile instruction to the created image") - // FIXME: --run is deprecated, it will be replaced with inline Dockerfile commands. - flags.StringVar(&opts.config, "run", "", "This option is deprecated and will be removed in a future version in favor of inline Dockerfile-compatible commands") - flags.MarkDeprecated("run", "it will be replaced with inline Dockerfile commands.") - return cmd } @@ -66,21 +59,12 @@ func runCommit(dockerCli *client.DockerCli, opts *commitOptions) error { name := opts.container reference := opts.reference - var config *containertypes.Config - if opts.config != "" { - config = &containertypes.Config{} - if err := json.Unmarshal([]byte(opts.config), config); err != nil { - return err - } - } - options := types.ContainerCommitOptions{ Reference: reference, Comment: opts.comment, Author: opts.author, Changes: opts.changes.GetAll(), Pause: opts.pause, - Config: config, } response, err := dockerCli.Client().ContainerCommit(ctx, name, options) diff --git a/docs/deprecated.md b/docs/deprecated.md index 668d8e89b4..907092c6a4 100644 --- a/docs/deprecated.md +++ b/docs/deprecated.md @@ -172,6 +172,15 @@ The single-dash (`-help`) was removed, in favor of the double-dash `--help` docker -help docker [COMMAND] -help +### `--run` flag on docker commit + +**Deprecated In Release: [v0.10.0](https://github.com/docker/docker/releases/tag/v0.10.0)** + +**Removed In Release: [v1.13.0](https://github.com/docker/docker/releases/)** + +The flag `--run` of the docker commit (and its short version `-run`) were deprecated in favor +of the `--changes` flag that allows to pass `Dockerfile` commands. + ### Interacting with V1 registries @@ -186,3 +195,4 @@ Since 1.9, Docker Content Trust Offline key has been renamed to Root key and the - DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE is now named DOCKER_CONTENT_TRUST_ROOT_PASSPHRASE - DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE is now named DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE + diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index a115a7d672..fcb2a672cd 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -438,72 +438,6 @@ func (s *DockerSuite) TestBuildEnvOverwrite(c *check.C) { } -func (s *DockerSuite) TestBuildOnBuildForbiddenMaintainerInSourceImage(c *check.C) { - name := "testbuildonbuildforbiddenmaintainerinsourceimage" - - out, _ := dockerCmd(c, "create", "busybox", "true") - - cleanedContainerID := strings.TrimSpace(out) - - dockerCmd(c, "commit", "--run", "{\"OnBuild\":[\"MAINTAINER docker.io\"]}", cleanedContainerID, "onbuild") - - _, err := buildImage(name, - `FROM onbuild`, - true) - if err != nil { - if !strings.Contains(err.Error(), "maintainer isn't allowed as an ONBUILD trigger") { - c.Fatalf("Wrong error %v, must be about MAINTAINER and ONBUILD in source image", err) - } - } else { - c.Fatal("Error must not be nil") - } - -} - -func (s *DockerSuite) TestBuildOnBuildForbiddenFromInSourceImage(c *check.C) { - name := "testbuildonbuildforbiddenfrominsourceimage" - - out, _ := dockerCmd(c, "create", "busybox", "true") - - cleanedContainerID := strings.TrimSpace(out) - - dockerCmd(c, "commit", "--run", "{\"OnBuild\":[\"FROM busybox\"]}", cleanedContainerID, "onbuild") - - _, err := buildImage(name, - `FROM onbuild`, - true) - if err != nil { - if !strings.Contains(err.Error(), "from isn't allowed as an ONBUILD trigger") { - c.Fatalf("Wrong error %v, must be about FROM and ONBUILD in source image", err) - } - } else { - c.Fatal("Error must not be nil") - } - -} - -func (s *DockerSuite) TestBuildOnBuildForbiddenChainedInSourceImage(c *check.C) { - name := "testbuildonbuildforbiddenchainedinsourceimage" - - out, _ := dockerCmd(c, "create", "busybox", "true") - - cleanedContainerID := strings.TrimSpace(out) - - dockerCmd(c, "commit", "--run", "{\"OnBuild\":[\"ONBUILD RUN ls\"]}", cleanedContainerID, "onbuild") - - _, err := buildImage(name, - `FROM onbuild`, - true) - if err != nil { - if !strings.Contains(err.Error(), "Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed") { - c.Fatalf("Wrong error %v, must be about chaining ONBUILD in source image", err) - } - } else { - c.Fatal("Error must not be nil") - } - -} - func (s *DockerSuite) TestBuildOnBuildCmdEntrypointJSON(c *check.C) { name1 := "onbuildcmd" name2 := "onbuildgenerated" diff --git a/integration-cli/docker_cli_commit_test.go b/integration-cli/docker_cli_commit_test.go index 086a203124..0a95c92f41 100644 --- a/integration-cli/docker_cli_commit_test.go +++ b/integration-cli/docker_cli_commit_test.go @@ -144,46 +144,3 @@ func (s *DockerSuite) TestCommitChange(c *check.C) { } } } - -// TODO: commit --run is deprecated, remove this once --run is removed -func (s *DockerSuite) TestCommitMergeConfigRun(c *check.C) { - testRequires(c, DaemonIsLinux) - name := "commit-test" - out, _ := dockerCmd(c, "run", "-d", "-e=FOO=bar", "busybox", "/bin/sh", "-c", "echo testing > /tmp/foo") - id := strings.TrimSpace(out) - - dockerCmd(c, "commit", `--run={"Cmd": ["cat", "/tmp/foo"]}`, id, "commit-test") - - out, _ = dockerCmd(c, "run", "--name", name, "commit-test") - //run config in committed container was not merged - c.Assert(strings.TrimSpace(out), checker.Equals, "testing") - - type cfg struct { - Env []string - Cmd []string - } - config1 := cfg{} - inspectFieldAndMarshall(c, id, "Config", &config1) - - config2 := cfg{} - inspectFieldAndMarshall(c, name, "Config", &config2) - - // Env has at least PATH loaded as well here, so let's just grab the FOO one - var env1, env2 string - for _, e := range config1.Env { - if strings.HasPrefix(e, "FOO") { - env1 = e - break - } - } - for _, e := range config2.Env { - if strings.HasPrefix(e, "FOO") { - env2 = e - break - } - } - - if len(config1.Env) != len(config2.Env) || env1 != env2 && env2 != "" { - c.Fatalf("expected envs to match: %v - %v", config1.Env, config2.Env) - } -}