Skip to content

Add support for --network=netns:/proc/pid/ns/net#271

Merged
runcom merged 1 commit intoprojectatomic:docker-1.12.6from
mrunalp:network_netns
Sep 15, 2017
Merged

Add support for --network=netns:/proc/pid/ns/net#271
runcom merged 1 commit intoprojectatomic:docker-1.12.6from
mrunalp:network_netns

Conversation

@mrunalp
Copy link
Copy Markdown

@mrunalp mrunalp commented Sep 14, 2017

To test this run a cri-o container and then get its pid and pass --network=netns:/proc/pid/ns/net of the cri-o container. You should then see the same ip a output inside both these containers.

@rhatdan @runcom

Signed-off-by: Mrunal Patel mrunalp@gmail.com

cc: @lsm5 we need a new rpm as soon as this is merged.

Comment thread daemon/container_operations.go Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I cannot test this patch with 1.12.6 because I'm on Fedora 26 but I ported the patch to 1.13.1 and I noticed there are other code paths in this file where you should call mode.IsNetNs() and exit before docker can continue setting up network.

@runcom
Copy link
Copy Markdown
Collaborator

runcom commented Sep 15, 2017

See #272 for a review and the port to 1.13.1 as well

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
@mrunalp
Copy link
Copy Markdown
Author

mrunalp commented Sep 15, 2017

Updated.

@runcom
Copy link
Copy Markdown
Collaborator

runcom commented Sep 15, 2017

LGTM, but there's no way I can test this out unfortunately :(

@mrunalp
Copy link
Copy Markdown
Author

mrunalp commented Sep 15, 2017

I tested it on Fedora 26.

@runcom runcom merged commit 638a809 into projectatomic:docker-1.12.6 Sep 15, 2017
@mrunalp
Copy link
Copy Markdown
Author

mrunalp commented Sep 18, 2017

@lsm5 can we build a new docker rpm with this?

@bparees
Copy link
Copy Markdown

bparees commented Sep 18, 2017

@mrunalp @runcom i'm preparing to consume this but i don't know how to determine my container's pid:

To test this run a cri-o container and then get its pid and pass --network=netns:/proc/pid/ns/net of the cri-o container. You should then see the same ip a output inside both these containers.

since my logic is running inside the pod, as far as it's concerned it's pid is "1".

@mrunalp
Copy link
Copy Markdown
Author

mrunalp commented Sep 18, 2017

@bparees We need two things. 1. pid 2. path to resolv.conf
Both of these are available in the inspect endpoint served by the crio unix socket /var/run/crio.sock at /containers/id
You should bind mount the resolv.conf path to /etc/resolv.conf i.e. the equivalent of docker run -v /path/you/get/from/inspect/:/etc/resolv.conf

@mrunalp
Copy link
Copy Markdown
Author

mrunalp commented Sep 18, 2017

@bparees See https://github.com/google/cadvisor/pull/1741/files for an example on how to talk to cri-o inspect endpoint. Also, resolv.conf path will be returned as part of annotations.

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.

3 participants