Skip to content
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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/podman-run.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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

These include `/etc/hosts`, `/etc/hostname`, and `/etc/resolv.conf` to manage
networking. These will be based on the host's version of the files, though they
can be customized with options (for example, **--dns** will override the host's
DNS servers in the created `resolv.conf`). Additionally, an empty file is
created in each container to indicate to programs they are running in a
container. This file is located at `/run/.containerenv`.

## OPTIONS
**--add-host**=[]
Add a custom host-to-IP mapping (host:ip)
Expand Down
11 changes: 11 additions & 0 deletions libpod/container_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,17 @@ func (c *Container) makeBindMounts() error {
c.state.BindMounts["/etc/hostname"] = hostnamePath
}

// Make .containerenv
Copy link
Member

Choose a reason for hiding this comment

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

nit /run/.containerenv

// Empty file, so no need to recreate if it exists
if _, ok := c.state.BindMounts["/run/.containerenv"]; !ok {
// Empty string for now, but we may consider populating this later
containerenvPath, err := c.writeStringToRundir(".containerenv", "")
if err != nil {
return errors.Wrapf(err, "error creating containerenv file for container %s", c.ID())
}
c.state.BindMounts["/run/.containerenv"] = containerenvPath
}

return nil
}

Expand Down