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

Allow chained network namespace containers #4629

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion libpod/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ func (c *Container) NetworkDisabled() (bool, error) {
if err != nil {
return false, err
}
return networkDisabled(container)
return container.NetworkDisabled()
}
return networkDisabled(c)

Expand Down
21 changes: 18 additions & 3 deletions libpod/container_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,24 @@ func (c *Container) makeBindMounts() error {
// We want /etc/resolv.conf and /etc/hosts from the
// other container. Unless we're not creating both of
// them.
depCtr, err := c.runtime.state.Container(c.config.NetNsCtr)
if err != nil {
return errors.Wrapf(err, "error fetching dependency %s of container %s", c.config.NetNsCtr, c.ID())
var (
depCtr *Container
nextCtr string
)

// I don't like infinite loops, but I don't think there's
// a serious risk of looping dependencies - too many
// protections against that elsewhere.
nextCtr = c.config.NetNsCtr
for {
depCtr, err = c.runtime.state.Container(nextCtr)
if err != nil {
return errors.Wrapf(err, "error fetching dependency %s of container %s", c.config.NetNsCtr, c.ID())
}
nextCtr = depCtr.config.NetNsCtr
if nextCtr == "" {
break
}
}

// We need that container's bind mounts
Expand Down