1
0
mirror of https://github.com/docker/cli.git synced 2026-01-15 07:40:57 +03:00

Add Test for port allocation bug (port already in use by other programs than docker)

Signed-off-by: Tibor Vass <teabee89@gmail.com>
Upstream-commit: 3109fc9537682a7b9ee566f3674484b1b2296707
Component: engine
This commit is contained in:
Tibor Vass
2014-09-05 18:59:31 -07:00
committed by Alexandr Morozov
parent 2bf1cd4824
commit d6bc3658af

View File

@@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"io/ioutil"
"net"
"os"
"os/exec"
"path"
@@ -1875,3 +1876,21 @@ func TestRunDeallocatePortOnMissingIptablesRule(t *testing.T) {
deleteAllContainers()
logDone("run - port should be deallocated even on iptables error")
}
func TestRunPortInUse(t *testing.T) {
port := "1234"
l, err := net.Listen("tcp", ":"+port)
if err != nil {
t.Fatal(err)
}
defer l.Close()
cmd := exec.Command(dockerBinary, "run", "-p", port+":80", "busybox", "true")
out, _, err := runCommandWithOutput(cmd)
if err == nil {
t.Fatalf("Host port %s already in use, has been allocated by docker: %q", port, out)
}
deleteAllContainers()
logDone("run - port in use")
}