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
5452670b
Kaydet (Commit)
5452670b
authored
Eyl 05, 2014
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #314 from mantiz/add-support-to-add-or-drop-capabilities
add support to add or drop capabilities
üst
e6af420a
95239508
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
2 deletions
+68
-2
README.md
README.md
+11
-1
client.py
docker/client.py
+7
-1
test.py
tests/test.py
+50
-0
No files found.
README.md
Dosyayı görüntüle @
5452670b
...
...
@@ -232,7 +232,8 @@ Identical to the `docker search` command.
```
python
c
.
start
(
container
,
binds
=
None
,
port_bindings
=
None
,
lxc_conf
=
None
,
publish_all_ports
=
False
,
links
=
None
,
privileged
=
False
,
dns
=
None
,
dns_search
=
None
,
volumes_from
=
None
,
network_mode
=
None
,
restart_policy
=
None
)
dns
=
None
,
dns_search
=
None
,
volumes_from
=
None
,
network_mode
=
None
,
restart_policy
=
None
,
cap_add
=
None
,
cap_drop
=
None
)
```
Similar to the
`docker start`
command, but doesn't support attach
...
...
@@ -278,6 +279,15 @@ for example:
}
```
`cap_add`
and
`cap_drop`
are available since v1.2.0 and can be used to add or drop certain capabilities.
The user may specify the capabilities as an array for example:
```
[
"SYS_ADMIN",
"MKNOD"
]
```
```
python
c
.
stop
(
container
,
timeout
=
10
)
...
...
docker/client.py
Dosyayı görüntüle @
5452670b
...
...
@@ -807,7 +807,7 @@ class Client(requests.Session):
def
start
(
self
,
container
,
binds
=
None
,
port_bindings
=
None
,
lxc_conf
=
None
,
publish_all_ports
=
False
,
links
=
None
,
privileged
=
False
,
dns
=
None
,
dns_search
=
None
,
volumes_from
=
None
,
network_mode
=
None
,
restart_policy
=
None
):
restart_policy
=
None
,
cap_add
=
None
,
cap_drop
=
None
):
if
isinstance
(
container
,
dict
):
container
=
container
.
get
(
'Id'
)
...
...
@@ -869,6 +869,12 @@ class Client(requests.Session):
if
restart_policy
:
start_config
[
'RestartPolicy'
]
=
restart_policy
if
cap_add
:
start_config
[
'CapAdd'
]
=
cap_add
if
cap_drop
:
start_config
[
'CapDrop'
]
=
cap_drop
url
=
self
.
_url
(
"/containers/{0}/start"
.
format
(
container
))
res
=
self
.
_post_json
(
url
,
data
=
start_config
)
self
.
_raise_for_status
(
res
)
...
...
tests/test.py
Dosyayı görüntüle @
5452670b
...
...
@@ -841,6 +841,56 @@ class DockerClientTest(Cleanup, unittest.TestCase):
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_start_container_with_added_capabilities
(
self
):
try
:
self
.
client
.
start
(
fake_api
.
FAKE_CONTAINER_ID
,
cap_add
=
[
'MKNOD'
])
except
Exception
as
e
:
self
.
fail
(
'Command should not raise exception: {0}'
.
format
(
e
))
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
0
],
url_prefix
+
'containers/3cc2351ab11b/start'
)
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
{
"PublishAllPorts"
:
False
,
"Privileged"
:
False
,
"CapAdd"
:
[
"MKNOD"
]}
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
}
)
self
.
assertEqual
(
args
[
1
][
'timeout'
],
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_start_container_with_dropped_capabilities
(
self
):
try
:
self
.
client
.
start
(
fake_api
.
FAKE_CONTAINER_ID
,
cap_drop
=
[
'MKNOD'
])
except
Exception
as
e
:
self
.
fail
(
'Command should not raise exception: {0}'
.
format
(
e
))
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
0
],
url_prefix
+
'containers/3cc2351ab11b/start'
)
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
{
"PublishAllPorts"
:
False
,
"Privileged"
:
False
,
"CapDrop"
:
[
"MKNOD"
]}
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
}
)
self
.
assertEqual
(
args
[
1
][
'timeout'
],
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_resize_container
(
self
):
try
:
self
.
client
.
resize
(
...
...
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