diff --git a/exegol/model/ExegolContainer.py b/exegol/model/ExegolContainer.py index f3b40194..30c1e8c3 100644 --- a/exegol/model/ExegolContainer.py +++ b/exegol/model/ExegolContainer.py @@ -41,7 +41,8 @@ def __init__(self, docker_container: Container, model: Optional[ExegolContainerT super().__init__(docker_container.name, config=ContainerConfig(docker_container), image=ExegolImage(name=image_name, docker_image=docker_image), - hostname=docker_container.attrs.get('Config', {}).get('Hostname')) + hostname=docker_container.attrs.get('Config', {}).get('Hostname'), + new_container=False) self.image.syncContainerData(docker_container) # At this stage, the container image object has an unknown status because no synchronization with a registry has been done. # This could be done afterwards (with container.image.autoLoad()) if necessary because it takes time. @@ -52,7 +53,8 @@ def __init__(self, docker_container: Container, model: Optional[ExegolContainerT config=ContainerConfig(docker_container), # Rebuild config from docker object to update workspace path image=model.image, - hostname=model.hostname) + hostname=model.hostname, + new_container=False) self.__new_container = True self.image.syncStatus() diff --git a/exegol/model/ExegolContainerTemplate.py b/exegol/model/ExegolContainerTemplate.py index 213f4ae3..7a727015 100644 --- a/exegol/model/ExegolContainerTemplate.py +++ b/exegol/model/ExegolContainerTemplate.py @@ -11,7 +11,7 @@ class ExegolContainerTemplate: """Exegol template class used to create a new container""" - def __init__(self, name: Optional[str], config: ContainerConfig, image: ExegolImage, hostname: Optional[str] = None): + def __init__(self, name: Optional[str], config: ContainerConfig, image: ExegolImage, hostname: Optional[str] = None, new_container: bool = True): if name is None: name = Prompt.ask("[bold blue][?][/bold blue] Enter the name of your new exegol container", default="default") assert name is not None @@ -20,12 +20,14 @@ def __init__(self, name: Optional[str], config: ContainerConfig, image: ExegolIm name = name.lower() self.container_name: str = name if name.startswith("exegol-") else f'exegol-{name}' self.name: str = name.replace('exegol-', '') + self.image: ExegolImage = image + self.config: ContainerConfig = config if hostname: self.hostname: str = hostname + if new_container: + self.config.addEnv("EXEGOL_NAME", self.container_name) else: self.hostname = self.container_name - self.image: ExegolImage = image - self.config: ContainerConfig = config def __str__(self): """Default object text formatter, debug only"""