From 9839e431c0ba8c374ce00733732762c944df3c4c Mon Sep 17 00:00:00 2001 From: VincentLeeMax Date: Wed, 12 Jul 2023 13:37:32 +0800 Subject: [PATCH] add commit pause option Signed-off-by: VincentLeeMax --- docker/api/container.py | 4 +++- docker/models/containers.py | 1 + tests/unit/api_image_test.py | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/api/container.py b/docker/api/container.py index 40607e79a..b8d5957b6 100644 --- a/docker/api/container.py +++ b/docker/api/container.py @@ -112,7 +112,7 @@ def attach_socket(self, container, params=None, ws=False): @utils.check_resource('container') def commit(self, container, repository=None, tag=None, message=None, - author=None, changes=None, conf=None): + author=None, pause=True, changes=None, conf=None): """ Commit a container to an image. Similar to the ``docker commit`` command. @@ -123,6 +123,7 @@ def commit(self, container, repository=None, tag=None, message=None, tag (str): The tag to push message (str): A commit message author (str): The name of the author + pause (bool): Whether to pause the container before committing changes (str): Dockerfile instructions to apply while committing conf (dict): The configuration for the container. See the `Engine API documentation @@ -139,6 +140,7 @@ def commit(self, container, repository=None, tag=None, message=None, 'tag': tag, 'comment': message, 'author': author, + 'pause': pause, 'changes': changes } u = self._url("/commit") diff --git a/docker/models/containers.py b/docker/models/containers.py index 2eeefda1e..64838397a 100644 --- a/docker/models/containers.py +++ b/docker/models/containers.py @@ -121,6 +121,7 @@ def commit(self, repository=None, tag=None, **kwargs): tag (str): The tag to push message (str): A commit message author (str): The name of the author + pause (bool): Whether to pause the container before committing changes (str): Dockerfile instructions to apply while committing conf (dict): The configuration for the container. See the `Engine API documentation diff --git a/tests/unit/api_image_test.py b/tests/unit/api_image_test.py index e28593294..b3428aa16 100644 --- a/tests/unit/api_image_test.py +++ b/tests/unit/api_image_test.py @@ -102,6 +102,7 @@ def test_commit(self): 'tag': None, 'container': fake_api.FAKE_CONTAINER_ID, 'author': None, + 'pause': True, 'changes': None }, timeout=DEFAULT_TIMEOUT_SECONDS