Skip to content

Commit ace2a7d

Browse files
authored
fix(tests): replace dind-test direct docker usage with sdk (#750)
fix: #749 Replace using `subprocess.run` in the **dind** test with SDK to avoid the direct call to docker that enforces the developer to run _sudoless_ docker.
1 parent 8d77bd3 commit ace2a7d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

core/tests/conftest.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import pytest
44
from typing import Callable
5-
import subprocess
65
from testcontainers.core.container import DockerClient
76
import sys
87

@@ -24,10 +23,12 @@ def python_testcontainer_image() -> str:
2423
"""Build an image with test containers python for DinD and DooD tests"""
2524
py_version = ".".join(map(str, sys.version_info[:2]))
2625
image_name = f"testcontainers-python:{py_version}"
27-
subprocess.run(
28-
[*("docker", "build"), *("--build-arg", f"PYTHON_VERSION={py_version}"), *("-t", image_name), "."],
29-
cwd=PROJECT_DIR,
30-
check=True,
26+
client = DockerClient()
27+
client.build(
28+
path=str(PROJECT_DIR),
29+
tag=image_name,
30+
rm=False,
31+
buildargs={"PYTHON_VERSION": py_version},
3132
)
3233
return image_name
3334

0 commit comments

Comments
 (0)