Skip to content

Commit 3af3855

Browse files
committed
Allow passing in extra args to Docker initialization
Puts it in the ContainerEngine interface specific to Docker, so PodMan can implement its own when necessary. Fixes #711
1 parent e3d0a9a commit 3af3855

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

repo2docker/docker.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import docker
6+
from traitlets import Dict
67
from iso8601 import parse_date
78

89
from .engine import Container, ContainerEngine, ContainerEngineException, Image
@@ -53,12 +54,26 @@ class DockerEngine(ContainerEngine):
5354

5455
string_output = False
5556

57+
extra_init_args = Dict(
58+
{},
59+
help="""
60+
Extra kwargs to pass to docker client when initializing it.
61+
62+
Dictionary that allows users to specify extra parameters to pass
63+
to APIClient, parameters listed in https://docker-py.readthedocs.io/en/stable/api.html#docker.api.client.APIClient.
64+
65+
Parameters here are merged with whatever is picked up from the
66+
environment.
67+
""",
68+
config=True,
69+
)
70+
5671
def __init__(self, *, parent):
5772
super().__init__(parent=parent)
5873
try:
59-
self._apiclient = docker.APIClient(
60-
version="auto", **docker.utils.kwargs_from_env()
61-
)
74+
kwargs = docker.utils.kwargs_from_env()
75+
kwargs.update(self.extra_init_args)
76+
self._apiclient = docker.APIClient(version="auto", **kwargs)
6277
except docker.errors.DockerException as e:
6378
raise ContainerEngineException("Check if docker is running on the host.", e)
6479

0 commit comments

Comments
 (0)