remove app
This commit is contained in:
@@ -140,7 +140,7 @@ class DockerInstaller:
|
||||
command.append(reference)
|
||||
self.command_runner.run(command)
|
||||
|
||||
def remove_container(self, container_name: str) -> None:
|
||||
def remove_container(self, container_name: str, remove_volumes: bool = False) -> None:
|
||||
result = self.command_runner.run([
|
||||
"docker",
|
||||
"ps",
|
||||
@@ -149,7 +149,34 @@ class DockerInstaller:
|
||||
f"name=^/{container_name}$",
|
||||
])
|
||||
if result.stdout.strip():
|
||||
self.command_runner.run(["docker", "rm", "-f", container_name])
|
||||
command = ["docker", "rm", "-f"]
|
||||
if remove_volumes:
|
||||
command.append("-v")
|
||||
command.append(container_name)
|
||||
self.command_runner.run(command)
|
||||
|
||||
def remove_labeled_containers(self, app_id: str, component_id: str, remove_volumes: bool = False) -> None:
|
||||
result = self.command_runner.run([
|
||||
"docker",
|
||||
"ps",
|
||||
"-aq",
|
||||
"--filter",
|
||||
f"label=local-installer-agent.app-id={app_id}",
|
||||
"--filter",
|
||||
f"label=local-installer-agent.component-id={component_id}",
|
||||
])
|
||||
container_ids = [line.strip() for line in result.stdout.splitlines() if line.strip()]
|
||||
if not container_ids:
|
||||
return
|
||||
|
||||
command = ["docker", "rm", "-f"]
|
||||
if remove_volumes:
|
||||
command.append("-v")
|
||||
command.extend(container_ids)
|
||||
self.command_runner.run(command)
|
||||
|
||||
def remove_image(self, reference: str) -> None:
|
||||
self.command_runner.run(["docker", "image", "rm", reference])
|
||||
|
||||
def assert_container_running(self, container_name: str) -> None:
|
||||
result = self.command_runner.run([
|
||||
|
||||
Reference in New Issue
Block a user