Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
6d8dff39
Kaydet (Commit)
6d8dff39
authored
Ock 28, 2017
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add prune_images method
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
a154092b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
14 deletions
+47
-14
image.py
docker/api/image.py
+25
-0
containers.py
docker/models/containers.py
+2
-14
images.py
docker/models/images.py
+4
-0
api_image_test.py
tests/integration/api_image_test.py
+16
-0
No files found.
docker/api/image.py
Dosyayı görüntüle @
6d8dff39
...
@@ -274,6 +274,31 @@ class ImageApiMixin(object):
...
@@ -274,6 +274,31 @@ class ImageApiMixin(object):
res
=
self
.
_post
(
self
.
_url
(
"/images/load"
),
data
=
data
)
res
=
self
.
_post
(
self
.
_url
(
"/images/load"
),
data
=
data
)
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@utils.minimum_version
(
'1.25'
)
def
prune_images
(
self
,
filters
=
None
):
"""
Delete unused images
Args:
filters (dict): Filters to process on the prune list.
Available filters:
- dangling (bool): When set to true (or 1), prune only
unused and untagged images.
Returns:
(dict): A dict containing a list of deleted image IDs and
the amount of disk space reclaimed in bytes.
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
url
=
self
.
_url
(
"/images/prune"
)
params
=
{}
if
filters
is
not
None
:
params
[
'filters'
]
=
utils
.
convert_filters
(
filters
)
return
self
.
_result
(
self
.
_post
(
url
,
params
=
params
),
True
)
def
pull
(
self
,
repository
,
tag
=
None
,
stream
=
False
,
def
pull
(
self
,
repository
,
tag
=
None
,
stream
=
False
,
insecure_registry
=
False
,
auth_config
=
None
,
decode
=
False
):
insecure_registry
=
False
,
auth_config
=
None
,
decode
=
False
):
"""
"""
...
...
docker/models/containers.py
Dosyayı görüntüle @
6d8dff39
import
copy
import
copy
from
..api
import
APIClient
from
..errors
import
(
ContainerError
,
ImageNotFound
,
from
..errors
import
(
ContainerError
,
ImageNotFound
,
create_unexpected_kwargs_error
)
create_unexpected_kwargs_error
)
from
..types
import
HostConfig
from
..types
import
HostConfig
...
@@ -764,21 +765,8 @@ class ContainerCollection(Collection):
...
@@ -764,21 +765,8 @@ class ContainerCollection(Collection):
return
[
self
.
get
(
r
[
'Id'
])
for
r
in
resp
]
return
[
self
.
get
(
r
[
'Id'
])
for
r
in
resp
]
def
prune
(
self
,
filters
=
None
):
def
prune
(
self
,
filters
=
None
):
"""
Delete stopped containers
Args:
filters (dict): Filters to process on the prune list.
Returns:
(dict): A dict containing a list of deleted container IDs and
the amount of disk space reclaimed in bytes.
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
return
self
.
client
.
api
.
prune_containers
(
filters
=
filters
)
return
self
.
client
.
api
.
prune_containers
(
filters
=
filters
)
prune
.
__doc__
=
APIClient
.
prune_containers
.
__doc__
# kwargs to copy straight from run to create
# kwargs to copy straight from run to create
...
...
docker/models/images.py
Dosyayı görüntüle @
6d8dff39
...
@@ -269,3 +269,7 @@ class ImageCollection(Collection):
...
@@ -269,3 +269,7 @@ class ImageCollection(Collection):
def
search
(
self
,
*
args
,
**
kwargs
):
def
search
(
self
,
*
args
,
**
kwargs
):
return
self
.
client
.
api
.
search
(
*
args
,
**
kwargs
)
return
self
.
client
.
api
.
search
(
*
args
,
**
kwargs
)
search
.
__doc__
=
APIClient
.
search
.
__doc__
search
.
__doc__
=
APIClient
.
search
.
__doc__
def
prune
(
self
,
filters
=
None
):
return
self
.
client
.
api
.
prune_images
(
filters
=
filters
)
prune
.
__doc__
=
APIClient
.
prune_images
.
__doc__
tests/integration/api_image_test.py
Dosyayı görüntüle @
6d8dff39
...
@@ -14,6 +14,7 @@ from six.moves import socketserver
...
@@ -14,6 +14,7 @@ from six.moves import socketserver
import
docker
import
docker
from
..helpers
import
requires_api_version
from
.base
import
BaseAPIIntegrationTest
,
BUSYBOX
from
.base
import
BaseAPIIntegrationTest
,
BUSYBOX
...
@@ -285,3 +286,18 @@ class ImportImageTest(BaseAPIIntegrationTest):
...
@@ -285,3 +286,18 @@ class ImportImageTest(BaseAPIIntegrationTest):
self
.
assertIn
(
'status'
,
result
)
self
.
assertIn
(
'status'
,
result
)
img_id
=
result
[
'status'
]
img_id
=
result
[
'status'
]
self
.
tmp_imgs
.
append
(
img_id
)
self
.
tmp_imgs
.
append
(
img_id
)
@requires_api_version
(
'1.25'
)
class
PruneImagesTest
(
BaseAPIIntegrationTest
):
def
test_prune_images
(
self
):
try
:
self
.
client
.
remove_image
(
'hello-world'
)
except
docker
.
errors
.
APIError
:
pass
self
.
client
.
pull
(
'hello-world'
)
self
.
tmp_imgs
.
append
(
'hello-world'
)
img_id
=
self
.
client
.
inspect_image
(
'hello-world'
)[
'Id'
]
result
=
self
.
client
.
prune_images
()
assert
img_id
in
result
[
'ImagesDeleted'
]
assert
result
[
'SpaceReclaimed'
]
>
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment