Allow setting of environment variables when importing docker images#7239
Allow setting of environment variables when importing docker images#7239rhatdan wants to merge 1 commit intomoby:masterfrom
Conversation
|
What about the other configuration options? Is ENV currently the only one that you think makes sense for a base image? |
|
I have a another patch for the COMMENT field. And we would like to add a META/Vendor field, to allow vendors to add json information to images. Have not thought of any thing else. But I would guess anything that can be added to the json file about a layer should be available to the Base IMage. |
|
Docs LGTM Ping @fredlf @SvenDowideit @ostezer |
|
Docs LGTM. |
|
same info needs to be added to the |
|
Updated cli.md |
|
docs LGTM |
|
Docs LGTM |
|
@crosbymichael Any other changes needed? |
|
ping @shykes this is a UI change to make it possible for image authors to set environment variables in the base image when they import the tarballs into docker. Please review. |
|
@crosbymichael @shykes Can this pull request get some love. Does not seem too controversial. |
|
I'm running this but it's not working. root@7c7f4212a8cd:/test# docker import -e="name=michael" - < busybox.tar
7ba3aaf318d1f88b61ae2e869ba95f2bab9c24653be7015cd57a92287aad081c
root@7c7f4212a8cd:/test# docker run 7ba3aaf318d1f88b61ae2e869ba95f2bab9c24653be7015cd57a92287aad081c env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=2c755fd6c190
HOME=/root |
|
I seemed to have lost a bit of the patch. For some reason I can not test this, although the json file looks like the content is there. How are you creating the busybox.tar? |
|
docker save -o /tmp/busybox.tar busybox:latest |
|
You have to use |
|
Thanks. Then why do we have docker save? docker import -e name=mike - < /tmp/dan docker run --rm -ti b66679d2d9cc /bin/shprintenvHOSTNAME=e55b555d0628 Seems to work. |
|
"docker save" correlates with "docker load" and saves all the layers as |
|
Well docker import should probably blow up if you use the output of docker save. Rather then giving you an image that can not be run. |
|
@crosbymichael Can you recheck this merge request? |
|
I'm getting a panic running the integration tests --- FAIL: TestExportContainerAndImportImage (0.74 seconds)
utils.go:125: failed to import image: panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x53d36d]
goroutine 16 [running]:
runtime.panic(0xb48340, 0x1174573)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
github.com/docker/docker/opts.(*ListOpts).String(0xc208037660, 0x0, 0x0)
/go/src/github.com/docker/docker/opts/opts.go:55 +0x11d
github.com/docker/docker/pkg/mflag.(*FlagSet).Var(0xc208004300, 0x7fd40b67c188, 0xc208037660, 0xc20803
76e0, 0x1, 0x1, 0xc98250, 0x36)
/go/src/github.com/docker/docker/pkg/mflag/flag.go:724 +0x43 |
|
Is there an easy way to run individual tests? |
|
You can set TESTFLAGS='-run TestName' when you run make test or however you are running the integration tests |
a0f3ec3 to
e2f23d5
Compare
|
This seems to be the error.
But I still can't get the test suite to run here. |
49c5f8d to
177cf52
Compare
177cf52 to
f023f97
Compare
|
This patch has been updated and seems to work for me. Back from Vacation, updating Pull Requests and seeing if there is anything I can do to move these along. |
f65d290 to
0435d91
Compare
|
Another week no action. |
|
@tianon I don't think this takes away from Dockerfile based building. You have to start from something and if you can get a complete base image into docker with all the configuration data then it's a big win. Also I hate it when I pull down a base image and it has multiple layers just for metadata :) I know that is how you have started building things so that you can only use dockerfiles but to keep a super small image I perfer the one layer with everything. |
|
LGTM |
|
LGTM |
|
Wouldn't having a generic configuration flag be better, rather than adding specific flags? I think having the possibility of setting configuration options for all commands which produce images would be better. A generic configuration flag could be used to provide all the configuration of the image in one layer. This configuration flag could also be used for commit. Please take this alternative option into consideration, we'll have to carry this flag and deprecate it if we decide to migrate to the generic configuration flag. |
|
This was the start of the last generic flag to mirror all the dockerfile options |
4047710 to
df5c0b0
Compare
|
What about having an option to make That way one would be able to add any metadata that docker end up exposing on |
There was a problem hiding this comment.
Maybe it's the passive voice, but I had a hard time understanding this sentence. It's hard to tell if the variables are used by the process or the container. Can you revise it to make that clearer?
There was a problem hiding this comment.
+-e, --env=environment
- Set environment variables. This option allows you to specify arbitrary
+environment variables that are available for the process that will be launched
How about?
Define arbitrary environment variables for the initial processes launched within the container.
There was a problem hiding this comment.
BTW, this comment was stolen from docker-run.1.md
-e, --env=environment
Set environment variables. This option allows you to specify arbitrary
environment variables that are available for the process that will be launched
inside of the container.
There was a problem hiding this comment.
Define arbitrary environment variables for the initial processes launched within the container.
I like that much better. LGTM from me (and sorry for slowness, I've been sick and slammed with work, a bad combo)
b3e3978 to
fb3ebd9
Compare
We want to be able to set the container=docker environment variable when we build RHEL docker images. I believe there will be other use cases where you might want to set environment in base images. Since you can do this in layered image, I see no reason not to allow it in base images. Docker-DCO-1.1-Signed-off-by: Dan Walsh <[email protected]> (github: rhatdan)
fb3ebd9 to
58e78ff
Compare
|
This patch will be replaced when #8332 gets merged with docker import support. |
|
@rhatdan Can we close this PR? |
|
Right as soon as we have docker import --change ENV:name=value |
|
ok cool! thanks :) |
|
Willing to work with the docker import --change patch. |
We want to be able to set the container=docker environment
variable when we build RHEL docker images. I believe there
will be other use cases where you might want to set
environment in base images.
Since you can do this in layered image, I see no reason not
to allow it in base images.
Docker-DCO-1.1-Signed-off-by: Dan Walsh [email protected] (github: rhatdan)