Commit f6ef959f authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[docker][Container] Added support to set container name

parent fc5a1655
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment