Issue #12130
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
| ... | ... |
@@ -3249,6 +3249,35 @@ func TestRunNetHost(t *testing.T) {
|
| 3249 | 3249 |
logDone("run - net host mode")
|
| 3250 | 3250 |
} |
| 3251 | 3251 |
|
| 3252 |
+func TestRunNetContainerWhichHost(t *testing.T) {
|
|
| 3253 |
+ testRequires(t, SameHostDaemon) |
|
| 3254 |
+ defer deleteAllContainers() |
|
| 3255 |
+ |
|
| 3256 |
+ hostNet, err := os.Readlink("/proc/1/ns/net")
|
|
| 3257 |
+ if err != nil {
|
|
| 3258 |
+ t.Fatal(err) |
|
| 3259 |
+ } |
|
| 3260 |
+ |
|
| 3261 |
+ cmd := exec.Command(dockerBinary, "run", "-d", "--net=host", "--name=test", "busybox", "top") |
|
| 3262 |
+ out, _, err := runCommandWithOutput(cmd) |
|
| 3263 |
+ if err != nil {
|
|
| 3264 |
+ t.Fatal(err, out) |
|
| 3265 |
+ } |
|
| 3266 |
+ |
|
| 3267 |
+ cmd = exec.Command(dockerBinary, "run", "--net=container:test", "busybox", "readlink", "/proc/self/ns/net") |
|
| 3268 |
+ out, _, err = runCommandWithOutput(cmd) |
|
| 3269 |
+ if err != nil {
|
|
| 3270 |
+ t.Fatal(err, out) |
|
| 3271 |
+ } |
|
| 3272 |
+ |
|
| 3273 |
+ out = strings.Trim(out, "\n") |
|
| 3274 |
+ if hostNet != out {
|
|
| 3275 |
+ t.Fatalf("Container should have host network namespace")
|
|
| 3276 |
+ } |
|
| 3277 |
+ |
|
| 3278 |
+ logDone("run - net container mode, where container in host mode")
|
|
| 3279 |
+} |
|
| 3280 |
+ |
|
| 3252 | 3281 |
func TestRunAllowPortRangeThroughPublish(t *testing.T) {
|
| 3253 | 3282 |
defer deleteAllContainers() |
| 3254 | 3283 |
|