Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.core
Commits
f6ef959f
Commit
f6ef959f
authored
Oct 01, 2018
by
Samuel GAIST
Browse files
[docker][Container] Added support to set container name
parent
fc5a1655
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/core/dock.py
View file @
f6ef959f
...
...
@@ -602,6 +602,14 @@ class Container:
self
.
_volumes
=
{}
self
.
_ports
=
{}
self
.
_stats
=
None
self
.
_name
=
None
def
set_name
(
self
,
name
):
""" Set the name to be used by the container in place of the docker
auto generated one.
"""
self
.
_name
=
name
def
add_volume
(
self
,
path
,
mount_path
,
read_only
=
True
):
...
...
@@ -646,6 +654,14 @@ class Container:
self
.
_ports
=
{}
@
property
def
name
(
self
):
name
=
''
if
self
.
_name
:
name
=
'--name=%s'
%
self
.
_name
return
name
@
property
def
volumes
(
self
):
"""Returns the volumes of this container in a suitable form to build
...
...
@@ -714,6 +730,7 @@ class Container:
cmd
+=
"%s "
%
self
.
user
cmd
+=
' '
.
join
(
self
.
volumes
)
cmd
+=
' '
.
join
(
self
.
ports
)
cmd
+=
"%s "
%
self
.
name
cmd
+=
"%s "
%
self
.
image
...
...
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