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
63df0b9a
Kaydet (Commit)
63df0b9a
authored
Agu 27, 2015
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge branch 'master' of github.com:docker/docker-py
üst
0282e120
db1a93fd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
+41
-2
client.py
docker/client.py
+6
-2
api.md
docs/api.md
+1
-0
integration_test.py
tests/integration_test.py
+34
-0
No files found.
docker/client.py
Dosyayı görüntüle @
63df0b9a
...
...
@@ -301,19 +301,23 @@ class Client(clientbase.ClientBase):
@check_resource
def
exec_create
(
self
,
container
,
cmd
,
stdout
=
True
,
stderr
=
True
,
tty
=
False
,
privileged
=
False
):
privileged
=
False
,
user
=
''
):
if
utils
.
compare_version
(
'1.15'
,
self
.
_version
)
<
0
:
raise
errors
.
InvalidVersion
(
'Exec is not supported in API < 1.15'
)
if
privileged
and
utils
.
compare_version
(
'1.19'
,
self
.
_version
)
<
0
:
raise
errors
.
InvalidVersion
(
'Privileged exec is not supported in API < 1.19'
)
if
user
and
utils
.
compare_version
(
'1.19'
,
self
.
_version
)
<
0
:
raise
errors
.
InvalidVersion
(
'User-specific exec is not supported in API < 1.19'
)
if
isinstance
(
cmd
,
six
.
string_types
):
cmd
=
shlex
.
split
(
str
(
cmd
))
data
=
{
'Container'
:
container
,
'User'
:
''
,
'User'
:
user
,
'Privileged'
:
privileged
,
'Tty'
:
tty
,
'AttachStdin'
:
False
,
...
...
docs/api.md
Dosyayı görüntüle @
63df0b9a
...
...
@@ -303,6 +303,7 @@ Sets up an exec instance in a running container.
*
stdout (bool): Attach to stdout of the exec command if true. Default: True
*
stderr (bool): Attach to stderr of the exec command if true. Default: True
*
tty (bool): Allocate a pseudo-TTY. Default: False
*
user (str): User to execute command as. Default: root
**Returns**
(dict): A dictionary with an exec 'Id' key.
...
...
tests/integration_test.py
Dosyayı görüntüle @
63df0b9a
...
...
@@ -895,6 +895,40 @@ class TestExecuteCommandString(BaseTestCase):
self
.
assertEqual
(
exec_log
,
expected
)
@unittest.skipIf
(
not
EXEC_DRIVER_IS_NATIVE
,
'Exec driver not native'
)
class
TestExecuteCommandStringAsUser
(
BaseTestCase
):
def
runTest
(
self
):
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
id
=
container
[
'Id'
]
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
id
)
res
=
self
.
client
.
exec_create
(
id
,
'whoami'
,
user
=
'default'
)
self
.
assertIn
(
'Id'
,
res
)
exec_log
=
self
.
client
.
exec_start
(
res
)
expected
=
b
'default'
if
six
.
PY3
else
'default
\n
'
self
.
assertEqual
(
exec_log
,
expected
)
@unittest.skipIf
(
not
EXEC_DRIVER_IS_NATIVE
,
'Exec driver not native'
)
class
TestExecuteCommandStringAsRoot
(
BaseTestCase
):
def
runTest
(
self
):
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
id
=
container
[
'Id'
]
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
id
)
res
=
self
.
client
.
exec_create
(
id
,
'whoami'
)
self
.
assertIn
(
'Id'
,
res
)
exec_log
=
self
.
client
.
exec_start
(
res
)
expected
=
b
'root'
if
six
.
PY3
else
'root
\n
'
self
.
assertEqual
(
exec_log
,
expected
)
@unittest.skipIf
(
not
EXEC_DRIVER_IS_NATIVE
,
'Exec driver not native'
)
class
TestExecuteCommandStreaming
(
BaseTestCase
):
def
runTest
(
self
):
...
...
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