Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add copyUIDGID support for container.put_archive() #3100

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions docker/api/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ def port(self, container, private_port):
return h_ports

@utils.check_resource('container')
def put_archive(self, container, path, data):
def put_archive(self, container, path, data, copy_uid_gid=False):
"""
Insert a file or folder in an existing container using a tar archive as
source.
Expand All @@ -967,6 +967,7 @@ def put_archive(self, container, path, data):
path (str): Path inside the container where the file(s) will be
extracted. Must exist.
data (bytes or stream): tar data to be extracted
copy_uid_gid (bool): copy UID/GID maps to the dest file or dir

Returns:
(bool): True if the call succeeds.
Expand All @@ -975,7 +976,7 @@ def put_archive(self, container, path, data):
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
params = {'path': path}
params = {'path': path, 'copyUIDGID': copy_uid_gid}
url = self._url('/containers/{0}/archive', container)
res = self._put(url, params=params, data=data)
self._raise_for_status(res)
Expand Down
5 changes: 3 additions & 2 deletions docker/models/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def pause(self):
"""
return self.client.api.pause(self.id)

def put_archive(self, path, data):
def put_archive(self, path, data, **kwargs):
"""
Insert a file or folder in this container using a tar archive as
source.
Expand All @@ -325,14 +325,15 @@ def put_archive(self, path, data):
path (str): Path inside the container where the file(s) will be
extracted. Must exist.
data (bytes or stream): tar data to be extracted
copy_uid_gid (bool): copy UID/GID maps to the dest file or dir

Returns:
(bool): True if the call succeeds.

Raises:
:py:class:`~docker.errors.APIError` If an error occurs.
"""
return self.client.api.put_archive(self.id, path, data)
return self.client.api.put_archive(self.id, path, data, **kwargs)

def remove(self, **kwargs):
"""
Expand Down