Remove terminated/unused docker containers from your system

Problem

After playing around with docker containers for some time the terminated/unused ones are still hanging around your system, and prevent you from using a new container with the same name as any of the previous ones with the error:

Error response from daemon: Conflict. The name "container_name" is already in use by container 61f023f06a98. You have to remove (or rename) that container to be able to reuse that name.

Solution

You can remove all the containers by using the following:

docker rm $(docker ps -aq)