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
cf68ebcd
Kaydet (Commit)
cf68ebcd
authored
May 12, 2017
tarafından
Joffrey F
Kaydeden (comit)
GitHub
May 12, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1604 from docker/1433-run-networks
Replace erroneous networks argument in containers.run
üst
007ab677
95297dc2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
10 deletions
+37
-10
containers.py
docker/models/containers.py
+15
-6
plugins.py
docker/models/plugins.py
+0
-0
services.py
docker/types/services.py
+1
-1
models_containers_test.py
tests/integration/models_containers_test.py
+19
-0
models_containers_test.py
tests/unit/models_containers_test.py
+2
-3
No files found.
docker/models/containers.py
Dosyayı görüntüle @
cf68ebcd
...
@@ -546,10 +546,12 @@ class ContainerCollection(Collection):
...
@@ -546,10 +546,12 @@ class ContainerCollection(Collection):
behavior. Accepts number between 0 and 100.
behavior. Accepts number between 0 and 100.
memswap_limit (str or int): Maximum amount of memory + swap a
memswap_limit (str or int): Maximum amount of memory + swap a
container is allowed to consume.
container is allowed to consume.
networks (:py:class:`list`): A list of network names to connect
this container to.
name (str): The name for this container.
name (str): The name for this container.
nano_cpus (int): CPU quota in units of 10-9 CPUs.
nano_cpus (int): CPU quota in units of 10-9 CPUs.
network (str): Name of the network this container will be connected
to at creation time. You can connect to additional networks
using :py:meth:`Network.connect`. Incompatible with
``network_mode``.
network_disabled (bool): Disable networking.
network_disabled (bool): Disable networking.
network_mode (str): One of:
network_mode (str): One of:
...
@@ -559,6 +561,7 @@ class ContainerCollection(Collection):
...
@@ -559,6 +561,7 @@ class ContainerCollection(Collection):
- ``container:<name|id>`` Reuse another container's network
- ``container:<name|id>`` Reuse another container's network
stack.
stack.
- ``host`` Use the host network stack.
- ``host`` Use the host network stack.
Incompatible with ``network``.
oom_kill_disable (bool): Whether to disable OOM killer.
oom_kill_disable (bool): Whether to disable OOM killer.
oom_score_adj (int): An integer value containing the score given
oom_score_adj (int): An integer value containing the score given
to the container in order to tune OOM killer preferences.
to the container in order to tune OOM killer preferences.
...
@@ -680,6 +683,12 @@ class ContainerCollection(Collection):
...
@@ -680,6 +683,12 @@ class ContainerCollection(Collection):
raise
RuntimeError
(
"The options 'detach' and 'remove' cannot be "
raise
RuntimeError
(
"The options 'detach' and 'remove' cannot be "
"used together."
)
"used together."
)
if
kwargs
.
get
(
'network'
)
and
kwargs
.
get
(
'network_mode'
):
raise
RuntimeError
(
'The options "network" and "network_mode" can not be used '
'together.'
)
try
:
try
:
container
=
self
.
create
(
image
=
image
,
command
=
command
,
container
=
self
.
create
(
image
=
image
,
command
=
command
,
detach
=
detach
,
**
kwargs
)
detach
=
detach
,
**
kwargs
)
...
@@ -902,10 +911,10 @@ def _create_container_args(kwargs):
...
@@ -902,10 +911,10 @@ def _create_container_args(kwargs):
if
volumes
:
if
volumes
:
host_config_kwargs
[
'binds'
]
=
volumes
host_config_kwargs
[
'binds'
]
=
volumes
network
s
=
kwargs
.
pop
(
'networks'
,
[]
)
network
=
kwargs
.
pop
(
'network'
,
None
)
if
network
s
:
if
network
:
create_kwargs
[
'networking_config'
]
=
{
network
:
None
create_kwargs
[
'networking_config'
]
=
{
network
:
None
}
for
network
in
networks
}
host_config_kwargs
[
'network_mode'
]
=
network
# All kwargs should have been consumed by this point, so raise
# All kwargs should have been consumed by this point, so raise
# error if any are left
# error if any are left
...
...
docker/models/plugins.py
Dosyayı görüntüle @
cf68ebcd
docker/types/services.py
Dosyayı görüntüle @
cf68ebcd
...
@@ -127,7 +127,7 @@ class ContainerSpec(dict):
...
@@ -127,7 +127,7 @@ class ContainerSpec(dict):
class
Mount
(
dict
):
class
Mount
(
dict
):
"""
"""
Describes a mounted folder's configuration inside a container. A list of
Describes a mounted folder's configuration inside a container. A list of
:py:class:`Mount`
s
would be used as part of a
:py:class:`Mount` would be used as part of a
:py:class:`~docker.types.ContainerSpec`.
:py:class:`~docker.types.ContainerSpec`.
Args:
Args:
...
...
tests/integration/models_containers_test.py
Dosyayı görüntüle @
cf68ebcd
import
docker
import
docker
import
tempfile
import
tempfile
from
.base
import
BaseIntegrationTest
,
TEST_API_VERSION
from
.base
import
BaseIntegrationTest
,
TEST_API_VERSION
from
..helpers
import
random_name
class
ContainerCollectionTest
(
BaseIntegrationTest
):
class
ContainerCollectionTest
(
BaseIntegrationTest
):
...
@@ -69,6 +70,24 @@ class ContainerCollectionTest(BaseIntegrationTest):
...
@@ -69,6 +70,24 @@ class ContainerCollectionTest(BaseIntegrationTest):
)
)
self
.
assertEqual
(
out
,
b
'hello
\n
'
)
self
.
assertEqual
(
out
,
b
'hello
\n
'
)
def
test_run_with_network
(
self
):
net_name
=
random_name
()
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
client
.
networks
.
create
(
net_name
)
self
.
tmp_networks
.
append
(
net_name
)
container
=
client
.
containers
.
run
(
'alpine'
,
'echo hello world'
,
network
=
net_name
,
detach
=
True
)
self
.
tmp_containers
.
append
(
container
.
id
)
attrs
=
container
.
attrs
assert
'NetworkSettings'
in
attrs
assert
'Networks'
in
attrs
[
'NetworkSettings'
]
assert
list
(
attrs
[
'NetworkSettings'
][
'Networks'
]
.
keys
())
==
[
net_name
]
def
test_get
(
self
):
def
test_get
(
self
):
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
container
=
client
.
containers
.
run
(
"alpine"
,
"sleep 300"
,
detach
=
True
)
container
=
client
.
containers
.
run
(
"alpine"
,
"sleep 300"
,
detach
=
True
)
...
...
tests/unit/models_containers_test.py
Dosyayı görüntüle @
cf68ebcd
...
@@ -71,8 +71,7 @@ class ContainerCollectionTest(unittest.TestCase):
...
@@ -71,8 +71,7 @@ class ContainerCollectionTest(unittest.TestCase):
memswap_limit
=
456
,
memswap_limit
=
456
,
name
=
'somename'
,
name
=
'somename'
,
network_disabled
=
False
,
network_disabled
=
False
,
network_mode
=
'blah'
,
network
=
'foo'
,
networks
=
[
'foo'
],
oom_kill_disable
=
True
,
oom_kill_disable
=
True
,
oom_score_adj
=
5
,
oom_score_adj
=
5
,
pid_mode
=
'host'
,
pid_mode
=
'host'
,
...
@@ -153,7 +152,7 @@ class ContainerCollectionTest(unittest.TestCase):
...
@@ -153,7 +152,7 @@ class ContainerCollectionTest(unittest.TestCase):
'MemoryReservation'
:
123
,
'MemoryReservation'
:
123
,
'MemorySwap'
:
456
,
'MemorySwap'
:
456
,
'MemorySwappiness'
:
2
,
'MemorySwappiness'
:
2
,
'NetworkMode'
:
'
blah
'
,
'NetworkMode'
:
'
foo
'
,
'OomKillDisable'
:
True
,
'OomKillDisable'
:
True
,
'OomScoreAdj'
:
5
,
'OomScoreAdj'
:
5
,
'PidMode'
:
'host'
,
'PidMode'
:
'host'
,
...
...
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