Use docker_name property when creating a container

This commit is contained in:
grossmj 2025-11-17 11:11:11 +10:00
parent bae6221991
commit 3a24318694
No known key found for this signature in database
GPG Key ID: 1E7DD6DBB53FF3D7

View File

@ -155,6 +155,10 @@ class DockerVM(BaseNode):
@property
def docker_name(self):
"""
Container name in Docker
"""
return "GNS3.{}.{}".format(self.name, self._project.id)
@property
@ -456,7 +460,7 @@ class DockerVM(BaseNode):
params["Env"].append("GNS3_EXTRA_HOSTS={}".format(extra_hosts))
# Support name in Doker: [a-zA-Z0-9][a-zA-Z0-9_.-]
result = await self.manager.query("POST", "containers/create?name=GNS3.{}.{}".format(self._name, self.project.id), data=params)
result = await self.manager.query("POST", "containers/create?name={}".format(self.docker_name), data=params)
self._cid = result['Id']
log.info("Docker container '{name}' [{id}] created".format(name=self._name, id=self._id))
return True