2018-01-24 14:45:55 +00:00
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2018-03-23 20:38:55 +00:00
|
|
|
"io/ioutil"
|
2018-11-28 11:46:39 +00:00
|
|
|
"net"
|
2018-01-24 14:45:55 +00:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2018-05-30 17:16:10 +00:00
|
|
|
"strings"
|
2018-01-24 14:45:55 +00:00
|
|
|
|
2018-10-29 06:56:07 +00:00
|
|
|
. "github.com/containers/libpod/test/utils"
|
2018-03-29 15:01:47 +00:00
|
|
|
"github.com/mrunalp/fileutils"
|
2018-01-24 14:45:55 +00:00
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("Podman run", func() {
|
|
|
|
var (
|
|
|
|
tempdir string
|
|
|
|
err error
|
2018-10-29 06:56:07 +00:00
|
|
|
podmanTest *PodmanTestIntegration
|
2018-01-24 14:45:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
BeforeEach(func() {
|
|
|
|
tempdir, err = CreateTempDirInTempDir()
|
|
|
|
if err != nil {
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2018-10-29 06:56:07 +00:00
|
|
|
podmanTest = PodmanTestCreate(tempdir)
|
2018-01-24 14:45:55 +00:00
|
|
|
podmanTest.RestoreAllArtifacts()
|
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
|
|
|
podmanTest.Cleanup()
|
2018-07-28 16:11:31 +00:00
|
|
|
f := CurrentGinkgoTestDescription()
|
|
|
|
timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
|
|
|
|
GinkgoWriter.Write([]byte(timedResult))
|
2018-01-24 14:45:55 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run a container based on local image", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", ALPINE, "ls"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
2018-09-26 18:19:45 +00:00
|
|
|
It("podman run a container based on a complex local image name", func() {
|
2018-10-30 15:34:38 +00:00
|
|
|
imageName := strings.TrimPrefix(nginx, "quay.io/")
|
2018-09-26 18:19:45 +00:00
|
|
|
podmanTest.RestoreArtifact(nginx)
|
2018-10-30 15:34:38 +00:00
|
|
|
session := podmanTest.Podman([]string{"run", imageName, "ls"})
|
2018-09-26 18:19:45 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ErrorToString()).ToNot(ContainSubstring("Trying to pull"))
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run a container based on on a short name with localhost", func() {
|
|
|
|
podmanTest.RestoreArtifact(nginx)
|
2018-11-01 15:31:44 +00:00
|
|
|
tag := podmanTest.Podman([]string{"tag", nginx, "localhost/libpod/alpine_nginx:latest"})
|
2018-09-26 18:19:45 +00:00
|
|
|
tag.WaitWithDefaultTimeout()
|
|
|
|
|
|
|
|
rmi := podmanTest.Podman([]string{"rmi", nginx})
|
|
|
|
rmi.WaitWithDefaultTimeout()
|
|
|
|
|
2018-11-01 15:31:44 +00:00
|
|
|
session := podmanTest.Podman([]string{"run", "libpod/alpine_nginx:latest", "ls"})
|
2018-09-26 18:19:45 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ErrorToString()).ToNot(ContainSubstring("Trying to pull"))
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
2018-01-24 14:45:55 +00:00
|
|
|
It("podman run a container based on local image with short options", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "-dt", ALPINE, "ls"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
2018-07-04 12:10:06 +00:00
|
|
|
It("podman run a container based on local image with short options and args", func() {
|
|
|
|
// regression test for #714
|
2018-09-13 19:12:04 +00:00
|
|
|
session := podmanTest.Podman([]string{"run", ALPINE, "find", "/etc", "-name", "hosts"})
|
2018-07-04 12:10:06 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
2018-09-13 19:12:04 +00:00
|
|
|
match, _ := session.GrepString("/etc/hosts")
|
2018-07-04 12:10:06 +00:00
|
|
|
Expect(match).Should(BeTrue())
|
|
|
|
})
|
|
|
|
|
2018-01-24 14:45:55 +00:00
|
|
|
It("podman run a container based on remote image", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "-dt", BB_GLIBC, "ls"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
2018-12-22 13:59:43 +00:00
|
|
|
It("podman run a container with --init", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--init", ALPINE, "ls"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run a container with --init and --init-path", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--init", "--init-path", "/usr/libexec/podman/catatonit", ALPINE, "ls"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
2018-05-29 09:41:57 +00:00
|
|
|
It("podman run seccomp test", func() {
|
|
|
|
jsonFile := filepath.Join(podmanTest.TempDir, "seccomp.json")
|
|
|
|
in := []byte(`{"defaultAction":"SCMP_ACT_ALLOW","syscalls":[{"name":"getcwd","action":"SCMP_ACT_ERRNO"}]}`)
|
|
|
|
err := WriteJsonFile(in, jsonFile)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
Skip("Failed to prepare seccomp.json for test.")
|
|
|
|
}
|
|
|
|
|
|
|
|
session := podmanTest.Podman([]string{"run", "-it", "--security-opt", strings.Join([]string{"seccomp=", jsonFile}, ""), ALPINE, "pwd"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Not(Equal(0)))
|
|
|
|
match, _ := session.GrepString("Operation not permitted")
|
|
|
|
Expect(match).Should(BeTrue())
|
|
|
|
})
|
|
|
|
|
2018-01-24 14:45:55 +00:00
|
|
|
It("podman run capabilities test", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--cap-add", "all", ALPINE, "cat", "/proc/self/status"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--cap-add", "sys_admin", ALPINE, "cat", "/proc/self/status"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--cap-drop", "all", ALPINE, "cat", "/proc/self/status"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--cap-drop", "setuid", ALPINE, "cat", "/proc/self/status"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run environment test", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--env", "FOO=BAR", ALPINE, "printenv", "FOO"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
match, _ := session.GrepString("BAR")
|
|
|
|
Expect(match).Should(BeTrue())
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--env", "PATH=/bin", ALPINE, "printenv", "PATH"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
match, _ = session.GrepString("/bin")
|
|
|
|
Expect(match).Should(BeTrue())
|
|
|
|
|
|
|
|
os.Setenv("FOO", "BAR")
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--env", "FOO", ALPINE, "printenv", "FOO"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
match, _ = session.GrepString("BAR")
|
|
|
|
Expect(match).Should(BeTrue())
|
|
|
|
os.Unsetenv("FOO")
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
// This currently does not work
|
|
|
|
// Re-enable when hostname is an env variable
|
2018-04-12 17:11:32 +00:00
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "sh", "-c", "printenv"})
|
|
|
|
session.Wait(10)
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
match, _ = session.GrepString("HOSTNAME")
|
|
|
|
Expect(match).Should(BeTrue())
|
2018-01-24 14:45:55 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run limits test", func() {
|
2018-02-06 19:34:44 +00:00
|
|
|
podmanTest.RestoreArtifact(fedoraMinimal)
|
2018-01-24 14:45:55 +00:00
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--ulimit", "rtprio=99", "--cap-add=sys_nice", fedoraMinimal, "cat", "/proc/self/sched"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--ulimit", "nofile=2048:2048", fedoraMinimal, "ulimit", "-n"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("2048"))
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--ulimit", "nofile=1024:1028", fedoraMinimal, "ulimit", "-n"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("1024"))
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--oom-kill-disable=true", fedoraMinimal, "echo", "memory-hog"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--oom-score-adj=100", fedoraMinimal, "cat", "/proc/self/oom_score_adj"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("100"))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run with volume flag", func() {
|
|
|
|
Skip("Skip until we diagnose the regression of volume mounts")
|
|
|
|
mountPath := filepath.Join(podmanTest.TempDir, "secrets")
|
|
|
|
os.Mkdir(mountPath, 0755)
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test", mountPath), ALPINE, "cat", "/proc/self/mountinfo"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("/run/test rw,relatime"))
|
|
|
|
|
|
|
|
mountPath = filepath.Join(podmanTest.TempDir, "secrets")
|
|
|
|
os.Mkdir(mountPath, 0755)
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:ro", mountPath), ALPINE, "cat", "/proc/self/mountinfo"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("/run/test ro,relatime"))
|
|
|
|
|
|
|
|
mountPath = filepath.Join(podmanTest.TempDir, "secrets")
|
|
|
|
os.Mkdir(mountPath, 0755)
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:shared", mountPath), ALPINE, "cat", "/proc/self/mountinfo"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("/run/test rw,relatime, shared"))
|
|
|
|
})
|
|
|
|
|
2018-11-27 07:59:55 +00:00
|
|
|
It("podman run with --mount flag", func() {
|
2018-10-30 15:34:38 +00:00
|
|
|
if podmanTest.Host.Arch == "ppc64le" {
|
|
|
|
Skip("skip failing test on ppc64le")
|
|
|
|
}
|
2018-09-21 10:29:18 +00:00
|
|
|
mountPath := filepath.Join(podmanTest.TempDir, "secrets")
|
|
|
|
os.Mkdir(mountPath, 0755)
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--mount", fmt.Sprintf("type=bind,src=%s,target=/run/test", mountPath), ALPINE, "grep", "/run/test", "/proc/self/mountinfo"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("/run/test rw"))
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--mount", fmt.Sprintf("type=bind,src=%s,target=/run/test,ro", mountPath), ALPINE, "grep", "/run/test", "/proc/self/mountinfo"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("/run/test ro"))
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--mount", fmt.Sprintf("type=bind,src=%s,target=/run/test,shared", mountPath), ALPINE, "grep", "/run/test", "/proc/self/mountinfo"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
2018-10-12 14:59:01 +00:00
|
|
|
found, matches := session.GrepString("/run/test")
|
|
|
|
Expect(found).Should(BeTrue())
|
|
|
|
Expect(matches[0]).To(ContainSubstring("rw"))
|
|
|
|
Expect(matches[0]).To(ContainSubstring("shared"))
|
2018-09-21 10:29:18 +00:00
|
|
|
|
|
|
|
mountPath = filepath.Join(podmanTest.TempDir, "scratchpad")
|
|
|
|
os.Mkdir(mountPath, 0755)
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "--mount", "type=tmpfs,target=/run/test", ALPINE, "grep", "/run/test", "/proc/self/mountinfo"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("/run/test rw,nosuid,nodev,noexec,relatime - tmpfs"))
|
|
|
|
})
|
|
|
|
|
2018-01-24 14:45:55 +00:00
|
|
|
It("podman run with cidfile", func() {
|
2018-09-08 10:58:47 +00:00
|
|
|
session := podmanTest.Podman([]string{"run", "--cidfile", tempdir + "cidfile", ALPINE, "ls"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
2018-09-08 10:58:47 +00:00
|
|
|
err := os.Remove(tempdir + "cidfile")
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(err).To(BeNil())
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run sysctl test", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--sysctl", "net.core.somaxconn=65535", ALPINE, "sysctl", "net.core.somaxconn"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("net.core.somaxconn = 65535"))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run blkio-weight test", func() {
|
2018-12-20 14:58:20 +00:00
|
|
|
if _, err := os.Stat("/sys/fs/cgroup/blkio/blkio.weight"); os.IsNotExist(err) {
|
|
|
|
Skip("Kernel does not support blkio.weight")
|
|
|
|
}
|
2018-01-24 14:45:55 +00:00
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--blkio-weight=15", ALPINE, "cat", "/sys/fs/cgroup/blkio/blkio.weight"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-24 14:45:55 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("15"))
|
|
|
|
})
|
2018-01-30 05:23:58 +00:00
|
|
|
|
2018-04-03 17:37:25 +00:00
|
|
|
It("podman run device-read-bps test", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--device-read-bps=/dev/zero:1mb", ALPINE, "cat", "/sys/fs/cgroup/blkio/blkio.throttle.read_bps_device"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("1048576"))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run device-write-bps test", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--device-write-bps=/dev/zero:1mb", ALPINE, "cat", "/sys/fs/cgroup/blkio/blkio.throttle.write_bps_device"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("1048576"))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run device-read-iops test", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--device-read-iops=/dev/zero:100", ALPINE, "cat", "/sys/fs/cgroup/blkio/blkio.throttle.read_iops_device"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("100"))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run device-write-iops test", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--device-write-iops=/dev/zero:100", ALPINE, "cat", "/sys/fs/cgroup/blkio/blkio.throttle.write_iops_device"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("100"))
|
|
|
|
})
|
|
|
|
|
2018-02-04 12:29:47 +00:00
|
|
|
It("podman run notify_socket", func() {
|
2018-11-28 11:46:39 +00:00
|
|
|
host := GetHostDistributionInfo()
|
|
|
|
if host.Distribution != "rhel" && host.Distribution != "centos" && host.Distribution != "fedora" {
|
|
|
|
Skip("this test requires a working runc")
|
|
|
|
}
|
|
|
|
sock := filepath.Join(podmanTest.TempDir, "notify")
|
|
|
|
addr := net.UnixAddr{
|
|
|
|
Name: sock,
|
|
|
|
Net: "unixgram",
|
|
|
|
}
|
|
|
|
socket, err := net.ListenUnixgram("unixgram", &addr)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
defer os.Remove(sock)
|
|
|
|
defer socket.Close()
|
|
|
|
|
2018-02-04 12:29:47 +00:00
|
|
|
os.Setenv("NOTIFY_SOCKET", sock)
|
2018-11-28 11:46:39 +00:00
|
|
|
defer os.Unsetenv("NOTIFY_SOCKET")
|
|
|
|
|
2018-02-04 12:29:47 +00:00
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "NOTIFY_SOCKET"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-02-04 12:29:47 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
2018-11-10 20:49:33 +00:00
|
|
|
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0))
|
2018-02-04 12:29:47 +00:00
|
|
|
})
|
|
|
|
|
2018-01-30 05:23:58 +00:00
|
|
|
It("podman run log-opt", func() {
|
|
|
|
log := filepath.Join(podmanTest.TempDir, "/container.log")
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--log-opt", fmt.Sprintf("path=%s", log), ALPINE, "ls"})
|
2018-02-23 16:18:23 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-01-30 05:23:58 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
_, err := os.Stat(log)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
_ = os.Remove(log)
|
|
|
|
})
|
|
|
|
|
2018-02-23 16:18:23 +00:00
|
|
|
It("podman run tagged image", func() {
|
|
|
|
tag := podmanTest.Podman([]string{"tag", "busybox", "bb"})
|
|
|
|
tag.WaitWithDefaultTimeout()
|
|
|
|
Expect(tag.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "bb", "ls"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
2018-03-29 15:01:47 +00:00
|
|
|
It("podman test hooks", func() {
|
|
|
|
hcheck := "/run/hookscheck"
|
2018-09-08 10:58:47 +00:00
|
|
|
hooksDir := tempdir + "/hooks"
|
2018-03-29 15:01:47 +00:00
|
|
|
os.Mkdir(hooksDir, 0755)
|
|
|
|
fileutils.CopyFile("hooks/hooks.json", hooksDir)
|
libpod/container_internal: Deprecate implicit hook directories
Part of the motivation for 800eb863 (Hooks supports two directories,
process default and override, 2018-09-17, #1487) was [1]:
> We only use this for override. The reason this was caught is people
> are trying to get hooks to work with CoreOS. You are not allowed to
> write to /usr/share... on CoreOS, so they wanted podman to also look
> at /etc, where users and third parties can write.
But we'd also been disabling hooks completely for rootless users. And
even for root users, the override logic was tricky when folks actually
had content in both directories. For example, if you wanted to
disable a hook from the default directory, you'd have to add a no-op
hook to the override directory.
Also, the previous implementation failed to handle the case where
there hooks defined in the override directory but the default
directory did not exist:
$ podman version
Version: 0.11.2-dev
Go Version: go1.10.3
Git Commit: "6df7409cb5a41c710164c42ed35e33b28f3f7214"
Built: Sun Dec 2 21:30:06 2018
OS/Arch: linux/amd64
$ ls -l /etc/containers/oci/hooks.d/test.json
-rw-r--r--. 1 root root 184 Dec 2 16:27 /etc/containers/oci/hooks.d/test.json
$ podman --log-level=debug run --rm docker.io/library/alpine echo 'successful container' 2>&1 | grep -i hook
time="2018-12-02T21:31:19-08:00" level=debug msg="reading hooks from /usr/share/containers/oci/hooks.d"
time="2018-12-02T21:31:19-08:00" level=warning msg="failed to load hooks: {}%!(EXTRA *os.PathError=open /usr/share/containers/oci/hooks.d: no such file or directory)"
With this commit:
$ podman --log-level=debug run --rm docker.io/library/alpine echo 'successful container' 2>&1 | grep -i hook
time="2018-12-02T21:33:07-08:00" level=debug msg="reading hooks from /usr/share/containers/oci/hooks.d"
time="2018-12-02T21:33:07-08:00" level=debug msg="reading hooks from /etc/containers/oci/hooks.d"
time="2018-12-02T21:33:07-08:00" level=debug msg="added hook /etc/containers/oci/hooks.d/test.json"
time="2018-12-02T21:33:07-08:00" level=debug msg="hook test.json matched; adding to stages [prestart]"
time="2018-12-02T21:33:07-08:00" level=warning msg="implicit hook directories are deprecated; set --hooks-dir="/etc/containers/oci/hooks.d" explicitly to continue to load hooks from this directory"
time="2018-12-02T21:33:07-08:00" level=error msg="container create failed: container_linux.go:336: starting container process caused "process_linux.go:399: container init caused \"process_linux.go:382: running prestart hook 0 caused \\\"error running hook: exit status 1, stdout: , stderr: oh, noes!\\\\n\\\"\""
(I'd setup the hook to error out). You can see that it's silenly
ignoring the ENOENT for /usr/share/containers/oci/hooks.d and
continuing on to load hooks from /etc/containers/oci/hooks.d.
When it loads the hook, it also logs a warning-level message
suggesting that callers explicitly configure their hook directories.
That will help consumers migrate, so we can drop the implicit hook
directories in some future release. When folks *do* explicitly
configure hook directories (via the newly-public --hooks-dir and
hooks_dir options), we error out if they're missing:
$ podman --hooks-dir /does/not/exist run --rm docker.io/library/alpine echo 'successful container'
error setting up OCI Hooks: open /does/not/exist: no such file or directory
I've dropped the trailing "path" from the old, hidden --hooks-dir-path
and hooks_dir_path because I think "dir(ectory)" is already enough
context for "we expect a path argument". I consider this name change
non-breaking because the old forms were undocumented.
Coming back to rootless users, I've enabled hooks now. I expect they
were previously disabled because users had no way to avoid
/usr/share/containers/oci/hooks.d which might contain hooks that
required root permissions. But now rootless users will have to
explicitly configure hook directories, and since their default config
is from ~/.config/containers/libpod.conf, it's a misconfiguration if
it contains hooks_dir entries which point at directories with hooks
that require root access. We error out so they can fix their
libpod.conf.
[1]: https://github.com/containers/libpod/pull/1487#discussion_r218149355
Signed-off-by: W. Trevor King <wking@tremily.us>
2018-12-03 05:22:08 +00:00
|
|
|
os.Setenv("HOOK_OPTION", fmt.Sprintf("--hooks-dir=%s", hooksDir))
|
2018-03-29 15:01:47 +00:00
|
|
|
os.Remove(hcheck)
|
|
|
|
session := podmanTest.Podman([]string{"run", ALPINE, "ls"})
|
|
|
|
session.Wait(10)
|
|
|
|
os.Unsetenv("HOOK_OPTION")
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
2018-03-23 20:38:55 +00:00
|
|
|
It("podman run with secrets", func() {
|
2018-04-26 15:29:02 +00:00
|
|
|
containersDir := filepath.Join(podmanTest.TempDir, "containers")
|
2018-03-23 20:38:55 +00:00
|
|
|
err := os.MkdirAll(containersDir, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
|
|
|
secretsDir := filepath.Join(podmanTest.TempDir, "rhel", "secrets")
|
|
|
|
err = os.MkdirAll(secretsDir, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
|
|
|
mountsFile := filepath.Join(containersDir, "mounts.conf")
|
|
|
|
mountString := secretsDir + ":/run/secrets"
|
|
|
|
err = ioutil.WriteFile(mountsFile, []byte(mountString), 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
|
|
|
secretsFile := filepath.Join(secretsDir, "test.txt")
|
|
|
|
secretsString := "Testing secrets mount. I am mounted!"
|
|
|
|
err = ioutil.WriteFile(secretsFile, []byte(secretsString), 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
2018-09-08 10:58:47 +00:00
|
|
|
targetDir := tempdir + "/symlink/target"
|
2018-04-12 18:41:17 +00:00
|
|
|
err = os.MkdirAll(targetDir, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
keyFile := filepath.Join(targetDir, "key.pem")
|
|
|
|
err = ioutil.WriteFile(keyFile, []byte(mountString), 0755)
|
|
|
|
Expect(err).To(BeNil())
|
2018-10-29 06:56:07 +00:00
|
|
|
execSession := SystemExec("ln", []string{"-s", targetDir, filepath.Join(secretsDir, "mysymlink")})
|
2018-04-12 18:41:17 +00:00
|
|
|
execSession.WaitWithDefaultTimeout()
|
|
|
|
Expect(execSession.ExitCode()).To(Equal(0))
|
|
|
|
|
2018-04-26 15:29:02 +00:00
|
|
|
session := podmanTest.Podman([]string{"--default-mounts-file=" + mountsFile, "run", "--rm", ALPINE, "cat", "/run/secrets/test.txt"})
|
2018-03-23 20:38:55 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
2018-04-12 18:41:17 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
2018-03-23 20:38:55 +00:00
|
|
|
Expect(session.OutputToString()).To(Equal(secretsString))
|
|
|
|
|
2018-04-26 15:29:02 +00:00
|
|
|
session = podmanTest.Podman([]string{"--default-mounts-file=" + mountsFile, "run", "--rm", ALPINE, "ls", "/run/secrets/mysymlink"})
|
2018-04-12 18:41:17 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("key.pem"))
|
2018-03-23 20:38:55 +00:00
|
|
|
})
|
|
|
|
|
2018-04-19 14:25:01 +00:00
|
|
|
It("podman run with FIPS mode secrets", func() {
|
|
|
|
fipsFile := "/etc/system-fips"
|
|
|
|
err = ioutil.WriteFile(fipsFile, []byte{}, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "ls", "/run/secrets"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("system-fips"))
|
|
|
|
|
|
|
|
err = os.Remove(fipsFile)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
})
|
|
|
|
|
2018-04-03 17:37:25 +00:00
|
|
|
It("podman run without group-add", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "id"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(Equal("uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)"))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run with group-add", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--group-add=audio", "--group-add=nogroup", "--group-add=777", ALPINE, "id"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(Equal("uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),18(audio),20(dialout),26(tape),27(video),777,65533(nogroup)"))
|
|
|
|
})
|
|
|
|
|
2018-04-20 13:44:37 +00:00
|
|
|
It("podman run with user (default)", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "id"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(Equal("uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)"))
|
|
|
|
})
|
|
|
|
|
2018-05-04 15:26:56 +00:00
|
|
|
It("podman run with user (integer, not in /etc/passwd)", func() {
|
2018-04-20 13:44:37 +00:00
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--user=1234", ALPINE, "id"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
2018-10-09 11:54:37 +00:00
|
|
|
Expect(session.OutputToString()).To(Equal("uid=1234(1234) gid=0(root)"))
|
2018-05-04 15:26:56 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run with user (integer, in /etc/passwd)", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--user=8", ALPINE, "id"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(Equal("uid=8(mail) gid=12(mail) groups=12(mail)"))
|
2018-04-20 13:44:37 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run with user (username)", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--user=mail", ALPINE, "id"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(Equal("uid=8(mail) gid=12(mail) groups=12(mail)"))
|
|
|
|
})
|
|
|
|
|
2018-05-04 15:26:56 +00:00
|
|
|
It("podman run with user:group (username:integer)", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--user=mail:21", ALPINE, "id"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(Equal("uid=8(mail) gid=21(ftp)"))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run with user:group (integer:groupname)", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--user=8:ftp", ALPINE, "id"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(Equal("uid=8(mail) gid=21(ftp)"))
|
|
|
|
})
|
|
|
|
|
2018-05-30 17:16:10 +00:00
|
|
|
It("podman run with user, verify caps dropped", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--user=1234", ALPINE, "grep", "CapEff", "/proc/self/status"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
capEff := strings.Split(session.OutputToString(), " ")
|
|
|
|
Expect("0000000000000000").To(Equal(capEff[1]))
|
|
|
|
})
|
|
|
|
|
2018-04-18 22:03:52 +00:00
|
|
|
It("podman run with attach stdin outputs container ID", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--attach", "stdin", ALPINE, "printenv"})
|
2018-04-12 17:11:32 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
2018-04-18 22:03:52 +00:00
|
|
|
ps := podmanTest.Podman([]string{"ps", "-aq", "--no-trunc"})
|
|
|
|
ps.WaitWithDefaultTimeout()
|
|
|
|
Expect(ps.ExitCode()).To(Equal(0))
|
|
|
|
Expect(ps.LineInOutputContains(session.OutputToString())).To(BeTrue())
|
2018-04-12 17:11:32 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run with attach stdout does not print stderr", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--attach", "stdout", ALPINE, "ls", "/doesnotexist"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.OutputToString()).To(Equal(""))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run with attach stderr does not print stdout", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--attach", "stderr", ALPINE, "ls", "/"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(Equal(""))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run attach nonsense errors", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", "--attach", "asdfasdf", ALPINE, "ls", "/"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(125))
|
|
|
|
})
|
|
|
|
|
2018-06-07 15:59:07 +00:00
|
|
|
It("podman run exit code on failure to exec", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", ALPINE, "/etc"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(126))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run error on exec", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", "exit 100"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(100))
|
|
|
|
})
|
2018-06-29 16:34:35 +00:00
|
|
|
|
|
|
|
It("podman run with built-in volume image", func() {
|
2018-07-31 14:05:48 +00:00
|
|
|
podmanTest.RestoreArtifact(redis)
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", redis, "ls"})
|
2018-06-29 16:34:35 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
2018-07-31 14:05:48 +00:00
|
|
|
session = podmanTest.Podman([]string{"rmi", redis})
|
2018-06-29 16:34:35 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
2018-07-03 17:55:59 +00:00
|
|
|
dockerfile := `FROM busybox
|
|
|
|
RUN mkdir -p /myvol/data && chown -R mail.0 /myvol
|
|
|
|
VOLUME ["/myvol/data"]
|
|
|
|
USER mail`
|
|
|
|
|
|
|
|
podmanTest.BuildImage(dockerfile, "test", "false")
|
|
|
|
session = podmanTest.Podman([]string{"run", "--rm", "test", "ls", "-al", "/myvol/data"})
|
2018-06-29 16:34:35 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
2018-07-03 17:55:59 +00:00
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("mail root"))
|
2018-06-29 16:34:35 +00:00
|
|
|
|
2018-07-03 17:55:59 +00:00
|
|
|
session = podmanTest.Podman([]string{"rmi", "test"})
|
2018-06-29 16:34:35 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
2018-06-11 19:27:42 +00:00
|
|
|
|
|
|
|
It("podman run --volumes-from flag", func() {
|
|
|
|
vol := filepath.Join(podmanTest.TempDir, "vol-test")
|
|
|
|
err := os.MkdirAll(vol, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
|
|
|
volFile := filepath.Join(vol, "test.txt")
|
|
|
|
data := "Testing --volumes-from!!!"
|
|
|
|
err = ioutil.WriteFile(volFile, []byte(data), 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
2018-07-31 14:05:48 +00:00
|
|
|
podmanTest.RestoreArtifact(redis)
|
|
|
|
session := podmanTest.Podman([]string{"create", "--volume", vol + ":/myvol", redis, "sh"})
|
2018-06-11 19:27:42 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
ctrID := session.OutputToString()
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--volumes-from", ctrID, ALPINE, "echo", "'testing read-write!' >> myvol/test.txt"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--volumes-from", ctrID + ":z", ALPINE, "ls"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run --volumes-from flag with built-in volumes", func() {
|
2018-07-31 14:05:48 +00:00
|
|
|
podmanTest.RestoreArtifact(redis)
|
|
|
|
session := podmanTest.Podman([]string{"create", redis, "sh"})
|
2018-06-11 19:27:42 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
ctrID := session.OutputToString()
|
|
|
|
|
|
|
|
session = podmanTest.Podman([]string{"run", "--volumes-from", ctrID, ALPINE, "ls"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
Expect(session.OutputToString()).To(ContainSubstring("data"))
|
|
|
|
|
|
|
|
})
|
2018-07-23 19:22:35 +00:00
|
|
|
|
|
|
|
It("podman run --volumes flag with multiple volumes", func() {
|
|
|
|
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
|
|
|
|
err := os.MkdirAll(vol1, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
vol2 := filepath.Join(podmanTest.TempDir, "vol-test2")
|
|
|
|
err = os.MkdirAll(vol2, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
2018-07-31 22:16:08 +00:00
|
|
|
session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:z", ALPINE, "touch", "/myvol2/foo.txt"})
|
2018-07-23 19:22:35 +00:00
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
2018-08-22 15:45:44 +00:00
|
|
|
|
2019-01-09 18:23:01 +00:00
|
|
|
It("podman run --volumes flag with empty host dir", func() {
|
|
|
|
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
|
|
|
|
err := os.MkdirAll(vol1, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
|
|
|
session := podmanTest.Podman([]string{"run", "--volume", ":/myvol1:z", ALPINE, "touch", "/myvol2/foo.txt"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).ToNot(Equal(0))
|
|
|
|
Expect(session.ErrorToString()).To(ContainSubstring("directory cannot be empty"))
|
|
|
|
session = podmanTest.Podman([]string{"run", "--volume", vol1 + ":", ALPINE, "touch", "/myvol2/foo.txt"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).ToNot(Equal(0))
|
|
|
|
Expect(session.ErrorToString()).To(ContainSubstring("directory cannot be empty"))
|
|
|
|
})
|
|
|
|
|
2018-09-21 10:29:18 +00:00
|
|
|
It("podman run --mount flag with multiple mounts", func() {
|
|
|
|
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
|
|
|
|
err := os.MkdirAll(vol1, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
vol2 := filepath.Join(podmanTest.TempDir, "vol-test2")
|
|
|
|
err = os.MkdirAll(vol2, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
|
|
|
session := podmanTest.Podman([]string{"run", "--mount", "type=bind,src=" + vol1 + ",target=/myvol1,z", "--mount", "type=bind,src=" + vol2 + ",target=/myvol2,z", ALPINE, "touch", "/myvol2/foo.txt"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
2018-08-22 15:45:44 +00:00
|
|
|
It("podman run findmnt nothing shared", func() {
|
2018-10-22 20:02:37 +00:00
|
|
|
podmanTest.RestoreArtifact(fedoraMinimal)
|
2018-08-22 15:45:44 +00:00
|
|
|
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
|
|
|
|
err := os.MkdirAll(vol1, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
vol2 := filepath.Join(podmanTest.TempDir, "vol-test2")
|
|
|
|
err = os.MkdirAll(vol2, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
|
|
|
session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:z", fedoraMinimal, "findmnt", "-o", "TARGET,PROPAGATION"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
match, _ := session.GrepString("shared")
|
|
|
|
Expect(match).Should(BeFalse())
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run findmnt shared", func() {
|
2018-10-22 20:02:37 +00:00
|
|
|
podmanTest.RestoreArtifact(fedoraMinimal)
|
2018-08-22 15:45:44 +00:00
|
|
|
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
|
|
|
|
err := os.MkdirAll(vol1, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
vol2 := filepath.Join(podmanTest.TempDir, "vol-test2")
|
|
|
|
err = os.MkdirAll(vol2, 0755)
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
|
|
|
session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:shared,z", fedoraMinimal, "findmnt", "-o", "TARGET,PROPAGATION"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
2018-11-21 14:56:31 +00:00
|
|
|
match, shared := session.GrepString("shared")
|
2018-08-22 15:45:44 +00:00
|
|
|
Expect(match).Should(BeTrue())
|
2018-11-21 14:56:31 +00:00
|
|
|
// make sure it's only shared (and not 'shared,slave')
|
|
|
|
isSharedOnly := !strings.Contains(shared[0], "shared,")
|
|
|
|
Expect(isSharedOnly).Should(BeTrue())
|
2018-08-22 15:45:44 +00:00
|
|
|
})
|
2018-11-30 16:23:28 +00:00
|
|
|
|
|
|
|
It("podman run --pod automatically", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--pod", "new:foobar", ALPINE, "ls"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
check := podmanTest.Podman([]string{"pod", "ps", "--no-trunc"})
|
|
|
|
check.WaitWithDefaultTimeout()
|
|
|
|
match, _ := check.GrepString("foobar")
|
|
|
|
Expect(match).To(BeTrue())
|
|
|
|
})
|
2018-12-11 22:10:35 +00:00
|
|
|
|
|
|
|
It("podman run --rm should work", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "ls"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
numContainers := podmanTest.NumberOfContainers()
|
|
|
|
Expect(numContainers).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run --rm failed container should delete itself", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "foo"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Not(Equal(0)))
|
|
|
|
|
|
|
|
numContainers := podmanTest.NumberOfContainers()
|
|
|
|
Expect(numContainers).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman run failed container should NOT delete itself", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", ALPINE, "foo"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Not(Equal(0)))
|
|
|
|
|
|
|
|
numContainers := podmanTest.NumberOfContainers()
|
|
|
|
Expect(numContainers).To(Equal(1))
|
|
|
|
})
|
2018-12-24 11:55:24 +00:00
|
|
|
It("podman run readonly container should NOT mount /dev/shm read/only", func() {
|
|
|
|
session := podmanTest.Podman([]string{"run", "--read-only", ALPINE, "mount"})
|
|
|
|
session.WaitWithDefaultTimeout()
|
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
Expect(session.OutputToString()).To(Not(ContainSubstring("/dev/shm type tmpfs (ro,")))
|
|
|
|
})
|
2018-01-24 14:45:55 +00:00
|
|
|
})
|