Docker Post Tag - TechOpt.io https://www.techopt.io/tag/docker Programming, servers, Linux, Windows, macOS & more Tue, 17 Jun 2025 02:38:48 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.3 https://www.techopt.io/wp-content/uploads/2024/07/cropped-logo-1-32x32.png Docker Post Tag - TechOpt.io https://www.techopt.io/tag/docker 32 32 Free Extra Disk Space Used by Docker https://www.techopt.io/programming/free-extra-disk-space-used-by-docker https://www.techopt.io/programming/free-extra-disk-space-used-by-docker#respond Tue, 16 Jul 2024 00:52:42 +0000 http://localhost:8080/?p=116 If you’ve been using Docker for awhile, you’ll likely notice that your free disk space keeps shrinking, specifically after pulling and updating images. This is because by default, Docker stores images and volumes even if they’re not in use anymore. If you’ve updated your containers, you may also have old versions of images stored that […]

The post Free Extra Disk Space Used by Docker appeared first on TechOpt.

]]>
If you’ve been using Docker for awhile, you’ll likely notice that your free disk space keeps shrinking, specifically after pulling and updating images. This is because by default, Docker stores images and volumes even if they’re not in use anymore. If you’ve updated your containers, you may also have old versions of images stored that you no longer need.

To free up some storage, we should delete these unnecessary images and volumes. We can use the docker system prune command to do so.

Free Disk Space by Pruning Unused Images

To remove unused images, use the following command:

docker system prune -a -f

The -a flag removes all unused images, and the -f flag skips confirmation.

Free Disk Space by Pruning Unused Volumes

Warning! This command may delete data created by the containers if the container volumes you want to keep aren’t in use. Therefore, use it at your own risk.

To remove unused volumes, use the following command:

docker system prune --volumes -f

The --volumes flag removes all unused volumes, and the -f flag skips confirmation.

Pruning Both Unused Images & Volumes

Warning! This command may delete data created by the containers if the container volumes you want to keep aren’t in use. Use it at your own risk.

To remove unused images and volumes together, use the following command:

docker system prune -a --volumes -f

The -a flag removes all unused images, the --volumes flag removes all unused volumes, and the -f flag skips confirmation.

Scheduling Pruning of Unused Images & Volumes

Unfortunately, at this time there is no way that is built into Docker to periodically prune unused images and volumes automatically.

However, if you’re on a *nix system, BSD system or macOS, you can use cron to periodically run one of the commands above periodically.

If you’re on Windows, you can use Task Scheduler to trigger one of the commands above.

Conclusion

By pruning unused images and volumes using the docker system prune command, you can often save tens of gigabytes of storage!

To see all the available flags for this command, please refer to the Docker documentation.

The post Free Extra Disk Space Used by Docker appeared first on TechOpt.

]]>
https://www.techopt.io/programming/free-extra-disk-space-used-by-docker/feed 0