diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 5385d95705..42223587ef 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -664,7 +664,7 @@ func (c *Container) makePlatformBindMounts() error { // Make /etc/hostname // This should never change, so no need to recreate if it exists if _, ok := c.state.BindMounts["/etc/hostname"]; !ok { - hostnamePath, err := c.writeStringToRundir("hostname", c.Hostname()) + hostnamePath, err := c.writeStringToRundir("hostname", c.Hostname()+"\n") if err != nil { return fmt.Errorf("creating hostname file for container %s: %w", c.ID(), err) } diff --git a/test/e2e/run_dns_test.go b/test/e2e/run_dns_test.go index 341831349a..126c17a741 100644 --- a/test/e2e/run_dns_test.go +++ b/test/e2e/run_dns_test.go @@ -60,7 +60,7 @@ var _ = Describe("Podman run dns", func() { session := podmanTest.Podman([]string{"run", "--hostname=foobar", ALPINE, "cat", "/etc/hostname"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - Expect(session.OutputToString()).To(Equal("foobar")) + Expect(string(session.Out.Contents())).To(Equal("foobar\n")) session = podmanTest.Podman([]string{"run", "--hostname=foobar", ALPINE, "hostname"}) session.WaitWithDefaultTimeout()