From 5b3503c0a1bf93dc327145e8952ed5b05932dee5 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Fri, 19 Jun 2020 06:41:58 -0400 Subject: Add container name to the /etc/hosts within the container This will allow containers that connect to the network namespace be able to use the container name directly. For example you can do something like podman run -ti --name foobar fedora ping foobar While we can do this with hostname now, this seems more natural. Also if another container connects on the network to this container it can do podman run --network container:foobar fedora ping foobar And connect to the original container,without having to discover the name. Signed-off-by: Daniel J Walsh --- test/e2e/run_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index c78c23b1f..7e75e2605 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -101,6 +101,18 @@ var _ = Describe("Podman run", func() { Expect(match).Should(BeTrue()) }) + It("podman create pod with name in /etc/hosts", func() { + name := "test_container" + hostname := "test_hostname" + session := podmanTest.Podman([]string{"run", "-ti", "--rm", "--name", name, "--hostname", hostname, ALPINE, "cat", "/etc/hosts"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + match, _ := session.GrepString(name) + Expect(match).Should(BeTrue()) + match, _ = session.GrepString(hostname) + Expect(match).Should(BeTrue()) + }) + It("podman run a container based on remote image", func() { session := podmanTest.Podman([]string{"run", "-dt", BB_GLIBC, "ls"}) session.WaitWithDefaultTimeout() -- cgit v1.2.3-54-g00ecf