Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jihogrammer/f3ca245be4b141b4f9880c03ed49574f to your computer and use it in GitHub Desktop.

Select an option

Save jihogrammer/f3ca245be4b141b4f9880c03ed49574f to your computer and use it in GitHub Desktop.
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
docker volume rm $(docker volume ls -qf)
# Remove all networks
docker network rm `docker network ls -q`
# Your installation should now be all fresh and clean.
# The following commands should not output any items:
# docker ps -a
# docker images -a
# docker volume ls
# The following command show only show the default networks:
# docker network ls
@jihogrammer
Copy link
Author

jihogrammer commented Jul 13, 2021

docker stop `docker ps -qa`

이와 같은 명령어를 Windows OS에서 사용 시 주의해야 한다.
Windows의 Commad(cmd)PowerShell에서는 동작하지 않는다.

정확한 원인은 모르겠지만 backtick으로 둘러 싼 부분의 실행 결과를
rm명령어의 args로 넘겨주는 방식으로 동작하는데,
아마 cmd나 powershell이 자체적으로 args를 생성하는 방법에서 docker와 충돌이 생기는 듯하다.

대안으로는 Git Bash가 있다. 기타 다른 Terminal은 사용해 본 적이 없어서 잘 모르겠다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment