Update update_docker_project.py
This commit is contained in:
@@ -65,6 +65,12 @@ def check_for_updates(images):
|
||||
updates[image] = image
|
||||
return updates
|
||||
|
||||
def remove_conflicting_containers(images):
|
||||
print("Usuwanie kolidujących kontenerów (jeśli istnieją)...")
|
||||
for image in images:
|
||||
name = image.split(":")[0].split("/")[-1]
|
||||
run(f"docker rm -f {name}", capture_output=True)
|
||||
|
||||
def prune_images():
|
||||
print("Czyszczenie nieużywanych obrazów...")
|
||||
run("docker image prune -f")
|
||||
@@ -85,17 +91,18 @@ def main():
|
||||
compose_cmd = detect_compose_command()
|
||||
images = get_images_from_compose(args.compose_file)
|
||||
|
||||
stop_containers(compose_cmd, args.compose_file, args.project_name)
|
||||
updated = check_for_updates(images)
|
||||
|
||||
if updated:
|
||||
stop_containers(compose_cmd, args.compose_file, args.project_name)
|
||||
print("Zaktualizowane obrazy:")
|
||||
for img in updated:
|
||||
print(f"- {img}")
|
||||
prune_images()
|
||||
remove_conflicting_containers(images)
|
||||
start_containers(compose_cmd, args.compose_file, args.project_name)
|
||||
else:
|
||||
print("Obrazy aktualne. Nie zatrzymuję i nie uruchamiam kontenerów.")
|
||||
print("Obrazy aktualne. Nie uruchamiam kontenerów.")
|
||||
|
||||
print("Zakończono.")
|
||||
|
||||
|
Reference in New Issue
Block a user