Skip to content

Commit 4ae0e01

Browse files
committed
Get the docker client api from the client
Getting the client api from the client reuses the client configuration. This fixes an inconsistency where environment variable configuration is used for the client but not for the client api. This change therefore enables environment variable configuration (ex DOCKER_HOST) to work.
1 parent 5eabf7d commit 4ae0e01

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

utils/oscap_docker_python/oscap_docker_util.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ class OscapDockerScan(object):
4242

4343
def __init__(self, target, is_image=False, oscap_binary='oscap'):
4444

45-
# init docker low level api (usefull for deep details like container pid)
46-
try:
47-
self.client = docker.APIClient()
48-
except AttributeError:
49-
self.client = docker.Client()
50-
5145
# init docker high level API (to deal with start/stop/run containers/image)
5246
self.client_api = docker.from_env()
5347
self.is_image = is_image
@@ -56,6 +50,9 @@ def __init__(self, target, is_image=False, oscap_binary='oscap'):
5650
self.container_name = None
5751
self.image_name = None
5852

53+
# init docker low level api (useful for deep details like container pid)
54+
self.client = self.client_api.api
55+
5956
if self.is_image:
6057
self.image_name, self.config = self._get_image_name_and_config(target)
6158
if self.image_name:

0 commit comments

Comments
 (0)