fix: Connect containers to Traefik network using network.connect() instead of broken network parameter
This commit is contained in:
parent
20a4d60f21
commit
65a2a6ed94
|
|
@ -64,7 +64,6 @@ class ContainerManager:
|
||||||
Config.USER_TEMPLATE_IMAGE,
|
Config.USER_TEMPLATE_IMAGE,
|
||||||
name=f"user-{slug}-{user_id}",
|
name=f"user-{slug}-{user_id}",
|
||||||
detach=True,
|
detach=True,
|
||||||
network=Config.TRAEFIK_NETWORK,
|
|
||||||
labels=labels,
|
labels=labels,
|
||||||
environment={
|
environment={
|
||||||
'USER_ID': str(user_id),
|
'USER_ID': str(user_id),
|
||||||
|
|
@ -75,6 +74,16 @@ class ContainerManager:
|
||||||
cpu_quota=Config.DEFAULT_CPU_QUOTA
|
cpu_quota=Config.DEFAULT_CPU_QUOTA
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Container an Traefik-Netzwerk verbinden
|
||||||
|
try:
|
||||||
|
network = self._get_client().networks.get(Config.TRAEFIK_NETWORK)
|
||||||
|
network.connect(container)
|
||||||
|
print(f"[SPAWNER] Container an Netzwerk '{Config.TRAEFIK_NETWORK}' verbunden")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[SPAWNER] WARNUNG: Container konnte nicht an Netzwerk verbunden werden: {str(e)}")
|
||||||
|
container.remove(force=True)
|
||||||
|
raise Exception(f"Konnte Container nicht an Netzwerk '{Config.TRAEFIK_NETWORK}' verbinden: {str(e)}")
|
||||||
|
|
||||||
print(f"[SPAWNER] Container created: {container.id[:12]}")
|
print(f"[SPAWNER] Container created: {container.id[:12]}")
|
||||||
print(f"[SPAWNER] URL: https://{base_host}/{slug}")
|
print(f"[SPAWNER] URL: https://{base_host}/{slug}")
|
||||||
return container.id, 8080
|
return container.id, 8080
|
||||||
|
|
@ -226,7 +235,6 @@ class ContainerManager:
|
||||||
image=image,
|
image=image,
|
||||||
name=container_name,
|
name=container_name,
|
||||||
detach=True,
|
detach=True,
|
||||||
network=Config.TRAEFIK_NETWORK,
|
|
||||||
labels=labels,
|
labels=labels,
|
||||||
environment={
|
environment={
|
||||||
'USER_ID': str(user_id),
|
'USER_ID': str(user_id),
|
||||||
|
|
@ -238,6 +246,16 @@ class ContainerManager:
|
||||||
cpu_quota=Config.DEFAULT_CPU_QUOTA
|
cpu_quota=Config.DEFAULT_CPU_QUOTA
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Container an Traefik-Netzwerk verbinden
|
||||||
|
try:
|
||||||
|
network = self._get_client().networks.get(Config.TRAEFIK_NETWORK)
|
||||||
|
network.connect(container)
|
||||||
|
print(f"[SPAWNER] Container an Netzwerk '{Config.TRAEFIK_NETWORK}' verbunden")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[SPAWNER] WARNUNG: Container konnte nicht an Netzwerk verbunden werden: {str(e)}")
|
||||||
|
container.remove(force=True)
|
||||||
|
raise Exception(f"Konnte Container nicht an Netzwerk '{Config.TRAEFIK_NETWORK}' verbinden: {str(e)}")
|
||||||
|
|
||||||
print(f"[SPAWNER] {container_type.upper()} container created: {container.id[:12]}")
|
print(f"[SPAWNER] {container_type.upper()} container created: {container.id[:12]}")
|
||||||
print(f"[SPAWNER] URL: {Config.PREFERRED_URL_SCHEME}://{base_host}/{slug_with_suffix}")
|
print(f"[SPAWNER] URL: {Config.PREFERRED_URL_SCHEME}://{base_host}/{slug_with_suffix}")
|
||||||
return container.id, 8080
|
return container.id, 8080
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user