diff options
author | Michael Scherer <misc@redhat.com> | 2021-11-12 12:56:57 +0100 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2021-12-06 14:24:06 -0500 |
commit | 4ed07fb67d11a875f10173a2a20e9149157b77ce (patch) | |
tree | 00fc71a644f7bcfa79372233d982ffcc79f53f82 /test | |
parent | 18e9ae59ca0800789ea6cfef3a27516801a7e1a5 (diff) | |
download | podman-4ed07fb67d11a875f10173a2a20e9149157b77ce.tar.gz podman-4ed07fb67d11a875f10173a2a20e9149157b77ce.tar.bz2 podman-4ed07fb67d11a875f10173a2a20e9149157b77ce.zip |
Always create working directory when using compat API
Docker/Moby always create the working directory, and some tools
rely on that behavior (example, woodpecker/drone).
Fixes #11842
Signed-off-by: Michael Scherer <misc@redhat.com>
<MH: Fixed cherry-pick conflicts>
Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/python/docker/compat/test_containers.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/python/docker/compat/test_containers.py b/test/python/docker/compat/test_containers.py index 1ad1e7f15..e6f7d992d 100644 --- a/test/python/docker/compat/test_containers.py +++ b/test/python/docker/compat/test_containers.py @@ -251,3 +251,17 @@ class TestContainers(unittest.TestCase): ctr.start() ret, out = ctr.exec_run(["stat", "-c", "%u:%g", "/workspace"]) self.assertEqual(out.rstrip(), b'1042:1043', "UID/GID set in dockerfile") + + + def test_non_existant_workdir(self): + dockerfile = (B'FROM quay.io/libpod/alpine:latest\n' + B'USER root\n' + B'WORKDIR /workspace/scratch\n' + B'RUN touch test') + img: Image + img, out = self.client.images.build(fileobj=io.BytesIO(dockerfile)) + ctr: Container = self.client.containers.create(image=img.id, detach=True, command="top", + volumes=["test_non_existant_workdir:/workspace"]) + ctr.start() + ret, out = ctr.exec_run(["stat", "/workspace/scratch/test"]) + self.assertEqual(ret, 0, "Working directory created if it doesn't exist") |