moby / moby/libnetwork

<HELP>Ethernet device moves among network namespaces

Open
#2,184 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.2k
Forks
875
PR merge metrics
No merged PRs in 30d

Description

Description

There're 2 devices on docker host: eth0 and eth1.
There's 1 additional network namespace: 3rd.
There's container name test, its PID is 1222.
Move eth1 from 1 to netns 3rd, then rename it to eth0, move it from 3rd to 1222.
Use docker rm -f to remove container.
Expect that eth1 can move back to netns 3rd.
But actual result is that eth1 move back to docker host root netns 1.
My question is:
Why cannot eth1 moves back to last network namespace "3rd" when container "test" is removed, but moved back to docker host root netns 1?
What's the design logic here? for container network namespace?
Actually my original purpose is that:
a. Use network device eth1 in container with the name eth0
b. Avoid network device name conflict when container is removed
Steps to reproduce the issue:

  1. ip netns add 3rd
  2. ip link set eth1 down
  3. ip link set eth1 netns 3rd
  4. ip netns exec 3rd ip link set eth1 name eth0
  5. ip netns exec 3rd ip link set eth0 netns 1222
  6. docker rm test -f

Describe the results you received:
eth1 moves back to docker host root netns 1.

Describe the results you expected:
eth1 moves back to netns 3rd.

Output of containerd --version:

docker -v
Docker version 18.05.0-ce, build f150324
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior with the listed ip netns, ip link, and docker commands. Then investigate how container removal handles a network device moved through multiple namespaces; done should establish whether restoring eth1 to the last namespace is intended and identify the required behavior or documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
networking
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.