mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 13:41:36 +00:00
Allow extra lines in /etc/hosts
This adds a --add-host host:ip flag which appends lines to /etc/hosts. This is needed in places where you want the container to get a different name resolution than it would through DNS. This was submitted before as #5525, closed, and now I am re-opening. It has come up 2 or 3 times in the last couple days. Signed-off-by: Tim Hockin <thockin@google.com>
This commit is contained in:
@@ -1331,6 +1331,23 @@ func TestDnsOptionsBasedOnHostResolvConf(t *testing.T) {
|
||||
logDone("run - dns options based on host resolv.conf")
|
||||
}
|
||||
|
||||
func TestRunAddHost(t *testing.T) {
|
||||
defer deleteAllContainers()
|
||||
cmd := exec.Command(dockerBinary, "run", "--add-host=extra:86.75.30.9", "busybox", "grep", "extra", "/etc/hosts")
|
||||
|
||||
out, _, err := runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
t.Fatal(err, out)
|
||||
}
|
||||
|
||||
actual := strings.Trim(out, "\r\n")
|
||||
if actual != "86.75.30.9\textra" {
|
||||
t.Fatalf("expected '86.75.30.9\textra', but says: '%s'", actual)
|
||||
}
|
||||
|
||||
logDone("run - add-host option")
|
||||
}
|
||||
|
||||
// Regression test for #6983
|
||||
func TestAttachStdErrOnlyTTYMode(t *testing.T) {
|
||||
cmd := exec.Command(dockerBinary, "run", "-t", "-a", "stderr", "busybox", "true")
|
||||
|
||||
Reference in New Issue
Block a user