-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add .containerenv file #533
Conversation
This will allow programs to easily identify they are running in a container Signed-off-by: Matthew Heon <[email protected]>
Fixed #529 |
matt this looks good. i wonder if this should be documented somewhere? Im not sure where frankly or I would say so ... but seems like something people might want to know. |
bot, retest this please |
LGTM and happy green test buttons. |
@baude We could put it in the manpages of |
Sounds as good of a place as any ... |
Should we move this to /run? |
Signed-off-by: Matthew Heon <[email protected]>
Comments addressed - added a section on files we create to the |
docs/podman-run.1.md
Outdated
@@ -21,6 +21,14 @@ If the IMAGE is not already loaded then **podman run** will pull the IMAGE, and | |||
all image dependencies, from the repository in the same way running **podman | |||
pull** IMAGE, before it starts the container from that image. | |||
|
|||
Several files will be automatically created within the container when it is run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't these files created at create/init time? Perhaps "... within the container and then updated based on run time parameters when it is run."
Although to be honest I'm struggling with the wording here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Init does happen within podman run
, so technically this is correct if we are talking about the run command? I don't know if there's an easy way to describe this bit within the manpage. Maybe we need a separate podman-containers manpage to describe things like this, so we can detail where in the lifecycle things happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lifecycle thing would be a great tutorial/blog post. Just so folks don't pick nits, what would you think about just dropping "when it is run" from the first sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a good compromise
@@ -672,6 +672,17 @@ func (c *Container) makeBindMounts() error { | |||
c.state.BindMounts["/etc/hostname"] = hostnamePath | |||
} | |||
|
|||
// Make .containerenv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit /run/.containerenv
Signed-off-by: Matthew Heon <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
systemd has some fancy code that I can not find quickly that figures out if is / is the host / and this determines if it is in a different mount namespace so it is in a container. But I can not find the code after 30 seconds of searching. |
bot, retest this please |
libpod/container_internal.go
Outdated
@@ -898,6 +909,7 @@ func (c *Container) generateSpec() (*spec.Spec, error) { | |||
|
|||
g.SetHostname(c.Hostname()) | |||
g.AddProcessEnv("HOSTNAME", g.Spec().Hostname) | |||
g.AddProcessEnv("CONTAINER", "libpod") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be lower-case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be done by buildah and podman not by the library.
I would rather see the fact that buildah created me or podman rather then libpod.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, fair enough.
Signed-off-by: Matthew Heon <[email protected]>
c59b29c
to
a21b575
Compare
📌 Commit a21b575 has been approved by |
⚡ Test exempted: merge already tested. |
Signed-off-by: Matthew Heon <[email protected]> Closes: #533 Approved by: baude
Signed-off-by: Matthew Heon <[email protected]> Closes: #533 Approved by: baude
Signed-off-by: Matthew Heon <[email protected]> Closes: #533 Approved by: baude
This will allow programs to easily identify they are running in a container
There was some discussion about putting it in /run, but I opted for just / to match Docker convention. Then again, we did rename the file...