Update update_docker_project.py
This commit is contained in:
@@ -65,6 +65,12 @@ def check_for_updates(images):
|
|||||||
updates[image] = image
|
updates[image] = image
|
||||||
return updates
|
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():
|
def prune_images():
|
||||||
print("Czyszczenie nieużywanych obrazów...")
|
print("Czyszczenie nieużywanych obrazów...")
|
||||||
run("docker image prune -f")
|
run("docker image prune -f")
|
||||||
@@ -85,17 +91,18 @@ def main():
|
|||||||
compose_cmd = detect_compose_command()
|
compose_cmd = detect_compose_command()
|
||||||
images = get_images_from_compose(args.compose_file)
|
images = get_images_from_compose(args.compose_file)
|
||||||
|
|
||||||
|
stop_containers(compose_cmd, args.compose_file, args.project_name)
|
||||||
updated = check_for_updates(images)
|
updated = check_for_updates(images)
|
||||||
|
|
||||||
if updated:
|
if updated:
|
||||||
stop_containers(compose_cmd, args.compose_file, args.project_name)
|
|
||||||
print("Zaktualizowane obrazy:")
|
print("Zaktualizowane obrazy:")
|
||||||
for img in updated:
|
for img in updated:
|
||||||
print(f"- {img}")
|
print(f"- {img}")
|
||||||
prune_images()
|
prune_images()
|
||||||
|
remove_conflicting_containers(images)
|
||||||
start_containers(compose_cmd, args.compose_file, args.project_name)
|
start_containers(compose_cmd, args.compose_file, args.project_name)
|
||||||
else:
|
else:
|
||||||
print("Obrazy aktualne. Nie zatrzymuję i nie uruchamiam kontenerów.")
|
print("Obrazy aktualne. Nie uruchamiam kontenerów.")
|
||||||
|
|
||||||
print("Zakończono.")
|
print("Zakończono.")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user