2015-07-08 16:30:03 -04:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
|
2016-12-30 12:23:00 -05:00
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
2015-07-08 16:30:03 -04:00
|
|
|
"github.com/go-check/check"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *DockerSuite) TestLinksEtcHostsContentMatch(c *check.C) {
|
2015-09-01 12:10:24 -04:00
|
|
|
// In a _unix file as using Unix specific files, and must be on the
|
|
|
|
// same host as the daemon.
|
2015-09-18 13:41:12 -04:00
|
|
|
testRequires(c, SameHostDaemon, NotUserNamespace)
|
2015-07-08 16:30:03 -04:00
|
|
|
|
2015-07-20 02:44:22 -04:00
|
|
|
out, _ := dockerCmd(c, "run", "--net=host", "busybox", "cat", "/etc/hosts")
|
2015-07-08 16:30:03 -04:00
|
|
|
hosts, err := ioutil.ReadFile("/etc/hosts")
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
c.Skip("/etc/hosts does not exist, skip this test")
|
|
|
|
}
|
|
|
|
|
2015-10-08 11:56:51 -04:00
|
|
|
c.Assert(out, checker.Equals, string(hosts), check.Commentf("container: %s\n\nhost:%s", out, hosts))
|
2015-07-08 16:30:03 -04:00
|
|
|
|
|
|
|
}
|