Skip to content

Patch to commit-change patch to add docker import support#9123

Merged
tiborvass merged 8 commits intomoby:masterfrom
rhatdan:commit-change
Feb 24, 2015
Merged

Patch to commit-change patch to add docker import support#9123
tiborvass merged 8 commits intomoby:masterfrom
rhatdan:commit-change

Conversation

@rhatdan
Copy link
Copy Markdown
Contributor

@rhatdan rhatdan commented Nov 12, 2014

pass --change changes to the import job

Docker-DCO-1.1-Signed-off-by: Dan Walsh [email protected] (github: rhatdan)

I have added a patch to #8765

Which implements docker import --change.

@rhatdan rhatdan changed the title Patch to origin/commit-change patch to add docker import support Patch to commit-change patch to add docker import support Nov 12, 2014
@SvenDowideit
Copy link
Copy Markdown
Contributor

Docs LGTM - @fredlf @jamtur01

@SvenDowideit
Copy link
Copy Markdown
Contributor

oh sneaky (copying from the original PR)

I think the docs need more info about side effects, or confirming that there are none - does the instruction run in the container, and so will persist if i docker start it again, or is the container commited, then a new one made based on that image, and the instruciton run in that temporary container..

@rhatdan
Copy link
Copy Markdown
Contributor Author

rhatdan commented Nov 13, 2014

I think the docs need more info about side effects, or confirming that there are none
Not sure what you mean about side effects. Basically what happens in a docker --commit or docker --import is you end up with an image and a json file containing any additional instructions given on --change line.

It will have the same output as if you had done your changes with a Dockerfile.

docker run -ti fedora /bin/sh
yum -y update
exit
docker commit --change "ENV foo bar" --change CMD /bin/init

Should give the same output as

cat Dockerfile
FROM fedora
RUN yum -y update
ENV foo bar
CMD /bin/init

does the instruction run in the container, and so will persist if i docker start it again, or is the container commited, then a new one made based on that image,
The commit/import and the change happen at the same layer their is no special commands, these are just adding data to the json file about the layer.

Comment thread docs/man/docker-commit.1.md Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change header to be consistent: "Modifying configuration settings before committing an image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And change its text to not imply that you're modifying the container, but creating new layers.

@SvenDowideit
Copy link
Copy Markdown
Contributor

mmm, @rhatdan that needs to be explained in the docs. So to confirm, each --change flag creates a new image layer?

ie, it needs to be clear that it does not modify the original container, but actually commits it, then applies each --change in turn in a new layer, tagging the final one...

@dqminh
Copy link
Copy Markdown
Contributor

dqminh commented Nov 14, 2014

@SvenDowideit iirc, all --change will be combined together and create only 1 layer ( that's how docker commit --change does it ).

@crosbymichael i think import will still having the same problem as commit because the current path is still passing --change data as URL params as we discussed before right ?

@rhatdan
Copy link
Copy Markdown
Contributor Author

rhatdan commented Nov 14, 2014

@dqminh @crosbymichael Well the import code is basically a cut and paste of the commit code. What is the problem with passing the --change data in the URL?

@SvenDowideit
Copy link
Copy Markdown
Contributor

@dqminh don't tell me :) it needs to be in the documentation!

Comment thread docs/man/docker-commit.1.md Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This heading is still misleading - you tell me that --change does not modify the container - it creates a new layer, ie, it commits the container, then creates a new layer containing the changes.

OR (reading the desciption below) you also seem to imply that this code change commits the container to an image, and also modifies that image layer in place with all the --change elements - if thats the case, then it needs to be clearly, and consistently explained - especially as the PR seems confused about what is actually happening.

I hope there are also unit tests exposing this...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does both in the same step. It commits or creates a new image with the Dockerfile instructions applied. There is a single layer, not multiple layers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhatdan Seems like this is basically the wording you're looking for, if you just tack on what "both" means at the beginning.

@SvenDowideit
Copy link
Copy Markdown
Contributor

ALSO. is there a limitation on the set of Dockerfile instructions that can be done via --change? because there seems to be nothing documenting which instructions can work.

@SvenDowideit
Copy link
Copy Markdown
Contributor

I can't see any tests showing if 2 new layers gets made (which imo would be the expectation most users would have), or there's only one layer, and then that different combinations of --change params get applied as expected.

I also don't see tests that make clear which instructions do and don't get applied - I'm assuming from the references to image JSON (which is new in the docs and would need more info too) that i can't --change RUN apt-get update && apt-get install -yq yum - but you havn't said.

@rhatdan
Copy link
Copy Markdown
Contributor Author

rhatdan commented Nov 17, 2014

  • Supported Dockerfile instructions: CMD, ENTRYPOINT, ENV, EXPOSE, ONBUILD, USER, VOLUME, WORKDIR

RUN/ADD are not supported.

When this patch gets applied, I plan on working on another patch to allow MAINTAINER to be applied. But I want this to get in first.

@rhatdan
Copy link
Copy Markdown
Contributor Author

rhatdan commented Nov 17, 2014

@SvenDowideit Please give me the wording you would like for the describing the one layer that gets created.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a copy paste issue or something happening here. Also, --change needs backticks.

@SvenDowideit
Copy link
Copy Markdown
Contributor

@rhatdan please see rhatdan#1

and once that's merged - LGTM - @fredlf @jamtur01

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dockerfile

@rhatdan
Copy link
Copy Markdown
Contributor Author

rhatdan commented Feb 13, 2015

Any update?

@tiborvass
Copy link
Copy Markdown
Contributor

@rhatdan I have this on my todo list, I'll review it today. I really want this too :)

@crosbymichael
Copy link
Copy Markdown
Contributor

This has the update to pass the changes via the url params via

for _, change := range flChanges.GetAll() {
        v.Add("changes", change)
}

This should be good to merged now if you can take another look.

@tiborvass @LK4D4

@crosbymichael crosbymichael removed their assignment Feb 20, 2015
@crosbymichael
Copy link
Copy Markdown
Contributor

LGTM

@rhatdan
Copy link
Copy Markdown
Contributor Author

rhatdan commented Feb 23, 2015

Two more LGTM to make my day...
@tiborvass @LK4D4

Comment thread api/server/server.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhatdan is this debug leftover ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I removed and repushed.

Comment thread docs/man/docker-commit.1.md Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instructions

dqminh and others added 8 commits February 24, 2015 13:01
Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <[email protected]> (github: dqminh)

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <[email protected]> (github: rhatdan)
Instead of building the actual image, `build_config` will serialize a subset of
dockerfile ast into *runconfig.Config

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <[email protected]> (github: dqminh)

Docker-DCO-1.1-Signed-off-by: Dan Walsh <[email protected]> (github: rhatdan)
In addition to config env, `commit` now will also accepts a `changes` env which
is a string contains new-line separated Dockerfile instructions.
`commit` will evaluate `changes` into `runconfig.Config` and merge it with
`config` env, and then finally commit a new image with the changed config

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <[email protected]> (github: dqminh)

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <[email protected]> (github: rhatdan)
Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <[email protected]> (github: dqminh)

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <[email protected]> (github: rhatdan)
Signed-off-by: Michael Crosby <[email protected]>

Docker-DCO-1.1-Signed-off-by: Michael Crosby <[email protected]> (github: rhatdan)
Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <[email protected]> (github: dqminh)

Docker-DCO-1.1-Signed-off-by: Dan Walsh <[email protected]> (github: rhatdan)
Docker-DCO-1.1-Signed-off-by: Dan Walsh <[email protected]> (github: rhatdan)
Docker-DCO-1.1-Signed-off-by: Dan Walsh <[email protected]> (github: rhatdan)
@tiborvass
Copy link
Copy Markdown
Contributor

LGTM

tiborvass added a commit that referenced this pull request Feb 24, 2015
Patch to commit-change patch to add docker import support
@tiborvass tiborvass merged commit e7dc7a6 into moby:master Feb 24, 2015
@ahmetb
Copy link
Copy Markdown
Contributor

ahmetb commented Feb 25, 2015

Hey folks this breaks if the busybox image in the test environment is not built from jpettazzo's busybox (https://github.com/docker/docker/blob/309eec23787d9e1e4de58b6475467a1af73c4c26/Dockerfile#L111) but rather pulled from docker hub (using docker pull busybox) because in the case of non-linux CLI tests we're running outside a container.

The busybox image on Docker Hub we pull in this case adds an extra PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin regardless of the --change parameter and the the test fails because inspected Config.Env has an extra PATH field. (https://github.com/docker/docker/blob/4a9fa9650b154e70d55f750c3674c2d6dd390bef/integration-cli/docker_cli_commit_test.go#L228)

How does it sound to add an extra --change ENV PATH /foo (and same in the expected string)? I tested it locally and it works fine. Is there any other way to get rid of that PATH added by busybox image on Docker Hub?

@tiborvass @dqminh @tianon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.