Reclaiming disk space without messing up my dev environments

Setup
Mac, docker desktop, 14 containers

Context
Drupal, wordpress, api, solr, react, etc development
Using docker compose and ddev
Using docker handson (so not really interested in how it works, but happy to work with it)

Problem
Running out of diskspace
Last time i reclaimed diskspace I lost all my local environments, had to rebuild all my containers from git and the production databases, so I really did something stupid. and cost me a lot of time.

I found some answers to the following (hopefully not too stupid) questions but but as I am pressed for time and deadlines am afraid to implement them.

f.i.
docker volume prune
docker rmi $(docker images -a)

Question 1
What is a save way to reclaim disk space?

Question 2
How can I backup an whole setup (so for a project all containers, images, volumes) so that when I destroy them I could easily restore them from my backup?

Hi.

I think the following command would be good for managing the image.

Compression (The file size decreases as it goes down)

docker image save [docker image name] > [save image name].tar

docker image save [docker image name] | gzip > [save image name].tar.gz

docker image save [docker image name] | bzip2 > [save image name].tar.bz2

Extract
docker image load < [docker image name].tar

I’m curious about other opinions than mine.
and other volume, log, network, etc

Have you read the Docker Desktop for Mac FAQ?

1 Like