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
8c4546f8
Kaydet (Commit)
8c4546f8
authored
Mar 17, 2016
tarafından
Daniel Nephin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #994 from aanand/janLo-tmpfs-support
tmpfs support
üst
7befe694
e5764172
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
145 additions
and
1 deletion
+145
-1
utils.py
docker/utils/utils.py
+35
-1
hostconfig.md
docs/hostconfig.md
+2
-0
tmpfs.md
docs/tmpfs.md
+33
-0
mkdocs.yml
mkdocs.yml
+1
-0
container_test.py
tests/integration/container_test.py
+16
-0
container_test.py
tests/unit/container_test.py
+58
-0
No files found.
docker/utils/utils.py
Dosyayı görüntüle @
8c4546f8
...
...
@@ -337,6 +337,35 @@ def convert_volume_binds(binds):
return
result
def
convert_tmpfs_mounts
(
tmpfs
):
if
isinstance
(
tmpfs
,
dict
):
return
tmpfs
if
not
isinstance
(
tmpfs
,
list
):
raise
ValueError
(
'Expected tmpfs value to be either a list or a dict, found: {}'
.
format
(
type
(
tmpfs
)
.
__name__
)
)
result
=
{}
for
mount
in
tmpfs
:
if
isinstance
(
mount
,
six
.
string_types
):
if
":"
in
mount
:
name
,
options
=
mount
.
split
(
":"
,
1
)
else
:
name
=
mount
options
=
""
else
:
raise
ValueError
(
"Expected item in tmpfs list to be a string, found: {}"
.
format
(
type
(
mount
)
.
__name__
)
)
result
[
name
]
=
options
return
result
def
parse_repository_tag
(
repo_name
):
parts
=
repo_name
.
rsplit
(
'@'
,
1
)
if
len
(
parts
)
==
2
:
...
...
@@ -584,7 +613,7 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
mem_limit
=
None
,
memswap_limit
=
None
,
mem_swappiness
=
None
,
cgroup_parent
=
None
,
group_add
=
None
,
cpu_quota
=
None
,
cpu_period
=
None
,
oom_kill_disable
=
False
,
shm_size
=
None
,
version
=
None
):
version
=
None
,
tmpfs
=
None
):
host_config
=
{}
...
...
@@ -751,6 +780,11 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
host_config
[
'CpuPeriod'
]
=
cpu_period
if
tmpfs
:
if
version_lt
(
version
,
'1.22'
):
raise
host_config_version_error
(
'tmpfs'
,
'1.22'
)
host_config
[
"Tmpfs"
]
=
convert_tmpfs_mounts
(
tmpfs
)
return
host_config
...
...
docs/hostconfig.md
Dosyayı görüntüle @
8c4546f8
...
...
@@ -111,6 +111,8 @@ for example:
container process will run as.
*
devices (list): Host device bindings. See
[
host devices
](
host-devices.md
)
for more information.
*
tmpfs: Temporary filesystems to mouunt. See
[
Using tmpfs
](
tmpfs.md
)
for more
information.
**Returns**
(dict) HostConfig dictionary
...
...
docs/tmpfs.md
0 → 100644
Dosyayı görüntüle @
8c4546f8
# Using tmpfs
When creating a container, you can specify paths to be mounted with tmpfs using
the
`tmpfs`
argument to
`create_host_config`
, similarly to the
`--tmpfs`
argument to
`docker run`
.
This capability is supported in Docker Engine 1.10 and up.
`tmpfs`
can be either a list or a dictionary. If it's a list, each item is a
string specifying the path and (optionally) any configuration for the mount:
```
python
client
.
create_container
(
'busybox'
,
'ls'
,
host_config
=
client
.
create_host_config
(
tmpfs
=
[
'/mnt/vol2'
,
'/mnt/vol1:size=3G,uid=1000'
])
)
```
Alternatively, if it's a dictionary, each key is a path and each value contains
the mount options:
```
python
client
.
create_container
(
'busybox'
,
'ls'
,
host_config
=
client
.
create_host_config
(
tmpfs
=
{
'/mnt/vol2'
:
''
,
'/mnt/vol1'
:
'size=3G,uid=1000'
})
)
```
mkdocs.yml
Dosyayı görüntüle @
8c4546f8
...
...
@@ -13,6 +13,7 @@ pages:
-
Host devices
:
host-devices.md
-
Host configuration
:
hostconfig.md
-
Network configuration
:
networks.md
-
Using tmpfs
:
tmpfs.md
-
Using with boot2docker
:
boot2docker.md
-
Change Log
:
change_log.md
-
Contributing
:
contributing.md
tests/integration/container_test.py
Dosyayı görüntüle @
8c4546f8
...
...
@@ -382,6 +382,22 @@ class CreateContainerTest(helpers.BaseTestCase):
sorted
([
'Foo'
,
'Other=one'
,
'Blank='
])
)
@requires_api_version
(
'1.22'
)
def
test_create_with_tmpfs
(
self
):
tmpfs
=
{
'/tmp1'
:
'size=3M'
}
container
=
self
.
client
.
create_container
(
BUSYBOX
,
[
'echo'
],
host_config
=
self
.
client
.
create_host_config
(
tmpfs
=
tmpfs
))
self
.
tmp_containers
.
append
(
container
[
'Id'
])
config
=
self
.
client
.
inspect_container
(
container
)
assert
config
[
'HostConfig'
][
'Tmpfs'
]
==
tmpfs
class
VolumeBindTest
(
helpers
.
BaseTestCase
):
def
setUp
(
self
):
...
...
tests/unit/container_test.py
Dosyayı görüntüle @
8c4546f8
...
...
@@ -1016,6 +1016,64 @@ class CreateContainerTest(DockerClientTest):
}
}}'''
))
@requires_api_version
(
'1.22'
)
def
test_create_container_with_tmpfs_list
(
self
):
self
.
client
.
create_container
(
'busybox'
,
'true'
,
host_config
=
self
.
client
.
create_host_config
(
tmpfs
=
[
"/tmp"
,
"/mnt:size=3G,uid=100"
]
)
)
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
1
],
url_prefix
+
'containers/create'
)
expected_payload
=
self
.
base_create_payload
()
expected_payload
[
'HostConfig'
]
=
self
.
client
.
create_host_config
()
expected_payload
[
'HostConfig'
][
'Tmpfs'
]
=
{
"/tmp"
:
""
,
"/mnt"
:
"size=3G,uid=100"
}
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
expected_payload
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
})
self
.
assertEqual
(
args
[
1
][
'timeout'
],
DEFAULT_TIMEOUT_SECONDS
)
@requires_api_version
(
'1.22'
)
def
test_create_container_with_tmpfs_dict
(
self
):
self
.
client
.
create_container
(
'busybox'
,
'true'
,
host_config
=
self
.
client
.
create_host_config
(
tmpfs
=
{
"/tmp"
:
""
,
"/mnt"
:
"size=3G,uid=100"
}
)
)
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
1
],
url_prefix
+
'containers/create'
)
expected_payload
=
self
.
base_create_payload
()
expected_payload
[
'HostConfig'
]
=
self
.
client
.
create_host_config
()
expected_payload
[
'HostConfig'
][
'Tmpfs'
]
=
{
"/tmp"
:
""
,
"/mnt"
:
"size=3G,uid=100"
}
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
expected_payload
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
})
self
.
assertEqual
(
args
[
1
][
'timeout'
],
DEFAULT_TIMEOUT_SECONDS
)
class
ContainerTest
(
DockerClientTest
):
def
test_list_containers
(
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