If you just dabble with Docker, or use it regularly, you will build an arsenal of images and containers as you go along. From time-to-time we need to clear these out. This process used to be more complicated until the docker command implemented a simpler way using system prune.
Remove all ‘dangling’ things (stopped containers, volumes, images)
docker system prune
Or run individually:
docker container prune
docker volume prune
docker image prune
docker network prune
As you can see in our screenshot, we had already run the prune command, so there was nothing else to remove :( but it would tell you how much space has been made available.
If you’re still curious how much space is being used, we can use system df.
docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 70 3.439GB 3.439GB (100%)Containers 00 0B 0B
Local Volumes 60 98.2MB 98.2MB (100%)Build Cache 00 0B 0B
Docker Setup for Go Development
This is a short and sweet article on running a Go application using Docker. This is a generic example and many use-cases will differ and so have totally different setups. In our examples we’re also using Docker and docker-compose both of which you will need already installed and setup on your machine for this to work.