From 9cd6cfd438ba4f034100331fc8b65c5f068e3c53 Mon Sep 17 00:00:00 2001 From: Alan Holt Date: Mon, 18 Aug 2025 17:09:01 -0500 Subject: [PATCH 1/2] fix link resolution for mounted volume on macos updated call to os.path.realpath inside assert_volumes to be os.path.abspath Fixes https://github.com/containers/podman-compose/issues/1290 Signed-off-by: Alan Holt --- podman_compose.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/podman_compose.py b/podman_compose.py index b4b24d54..a9d521b9 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -403,7 +403,7 @@ async def assert_volume(compose: PodmanCompose, mount_dict: dict[str, Any]) -> N if mount_dict["type"] == "bind": basedir = os.path.realpath(compose.dirname) mount_src = mount_dict["source"] - mount_src = os.path.realpath(os.path.join(basedir, os.path.expanduser(mount_src))) + mount_src = os.path.abspath(os.path.join(basedir, os.path.expanduser(mount_src))) if not os.path.exists(mount_src): bind_opts = mount_dict.get("bind", {}) if "create_host_path" in bind_opts and not bind_opts["create_host_path"]: From 9ead6ec8fb7e639d2a11cd2635b7b60e8ec217e2 Mon Sep 17 00:00:00 2001 From: Alan Holt Date: Tue, 26 Aug 2025 09:45:07 -0500 Subject: [PATCH 2/2] added integration test using docker.sock mount Signed-off-by: Alan Holt --- tests/integration/docker_sock/README.md | 4 ++ tests/integration/docker_sock/__init__.py | 1 + .../docker_sock/docker-compose.yaml | 14 ++++++ .../test_podman_compose_docker_sock.py | 45 +++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 tests/integration/docker_sock/README.md create mode 100644 tests/integration/docker_sock/__init__.py create mode 100644 tests/integration/docker_sock/docker-compose.yaml create mode 100644 tests/integration/docker_sock/test_podman_compose_docker_sock.py diff --git a/tests/integration/docker_sock/README.md b/tests/integration/docker_sock/README.md new file mode 100644 index 00000000..3f68c7f7 --- /dev/null +++ b/tests/integration/docker_sock/README.md @@ -0,0 +1,4 @@ +``` +podman-compose up +``` + diff --git a/tests/integration/docker_sock/__init__.py b/tests/integration/docker_sock/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/integration/docker_sock/__init__.py @@ -0,0 +1 @@ + diff --git a/tests/integration/docker_sock/docker-compose.yaml b/tests/integration/docker_sock/docker-compose.yaml new file mode 100644 index 00000000..33eae63f --- /dev/null +++ b/tests/integration/docker_sock/docker-compose.yaml @@ -0,0 +1,14 @@ +version: "3" +services: + web: + image: nopush/podman-compose-test + command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8000"] + working_dir: /var/www/html + restart: always + volumes: + - /var/www/html + - /var/run/docker.sock:/var/run/docker.sock + tmpfs: + - /run + - /tmp + diff --git a/tests/integration/docker_sock/test_podman_compose_docker_sock.py b/tests/integration/docker_sock/test_podman_compose_docker_sock.py new file mode 100644 index 00000000..cb8c4ef1 --- /dev/null +++ b/tests/integration/docker_sock/test_podman_compose_docker_sock.py @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: GPL-2.0 + +""" +test_podman_compose_up_down.py + +Tests the podman compose up and down commands used to create and remove services. +""" + +# pylint: disable=redefined-outer-name +import os +import unittest + +from tests.integration.test_utils import RunSubprocessMixin +from tests.integration.test_utils import podman_compose_path +from tests.integration.test_utils import test_path + + +class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin): + def test_with_docker_sock(self) -> None: + up_cmd = [ + "coverage", + "run", + podman_compose_path(), + "-f", + os.path.join(test_path(), "docker_sock", "docker-compose.yaml"), + "up", + "-d", + ] + + down_cmd = [ + "coverage", + "run", + podman_compose_path(), + "-f", + os.path.join(test_path(), "docker_sock", "docker-compose.yaml"), + "down", + "--volumes", + ] + + try: + self.run_subprocess_assert_returncode(up_cmd) + + finally: + out, _, return_code = self.run_subprocess(down_cmd) + self.assertEqual(return_code, 0)