Skip to content

Commit 3dbd424

Browse files
authored
fix(dogfood/coder): stop docker containers and prune system on shutdown (#17904)
This change adds docker stop and docker system prune to the shutdown script so that it doesn't need to be done by the Docker host which will take a lot longer. This change greatly speeds up workspace destruction: ``` 2025-05-19 12:26:57.046+03:00 docker_container.workspace[0]: Destroying... [id=2685e2f456ba7b280c420219f19ef15384faa52c61ba7c087c7f109ffa6b1bda] 2025-05-19 12:27:07.046+03:00 docker_container.workspace[0]: Still destroying... [10s elapsed] 2025-05-19 12:27:16.734+03:00 docker_container.workspace[0]: Destruction complete after 20s ``` Follow-up for #17110
1 parent 98e2ec4 commit 3dbd424

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

dogfood/coder/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,17 @@ resource "coder_agent" "dev" {
373373
#!/usr/bin/env bash
374374
set -eux -o pipefail
375375
376+
# Stop all running containers and prune the system to clean up
377+
# /var/lib/docker to prevent errors during workspace destroy.
378+
#
379+
# WARNING! This will remove:
380+
# - all containers
381+
# - all networks
382+
# - all images
383+
# - all build cache
384+
docker ps -q | xargs docker stop
385+
docker system prune -a
386+
376387
# Stop the Docker service to prevent errors during workspace destroy.
377388
sudo service docker stop
378389
EOT

0 commit comments

Comments
 (0)