On Windows and MacOS you can use Docker for Desktop.
On Ubuntu follow the steps below which are also summarized in this script.
sudo apt update
sudo apt install docker.io
Start Docker:
$ sudo systemctl start docker
Test Docker with sudo
:
$ sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
Prepare Docker to work to work without root:
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
Run hello-world without sudo
.
$ docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
And reboot the virtual machine to ensure that the permissions are fixed.
Let's keep the house in order.
- Purging All Unused or Dangling Images, Containers, Volumes, and Networks
docker system prune
- To additionally remove any stopped containers and all unused images (not just dangling images), add the -a flag to the command:
docker system prune -a
- Remove all images
- List:
docker images -a
- Remove all:
docker rmi $(docker images -a -q)
- Remove individual by name:
docker rmi Image Image
- List certain images only:
docker images -a | grep "pattern"
- Remove these images:
docker images -a | grep "pattern" | awk '{print $3}' | xargs docker rmi
- List:
docker ps -a
- Remove all:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
- Remove individual containers:
docker rm ID_or_Name ID_or_Name
- List:
docker ps -a -f status=exited
- Remove:
docker rm $(docker ps -a -f status=exited -q)
- List:
docker ps -a | grep "pattern”
- Remove:
docker ps -a | grep "pattern" | awk '{print $1}' | xargs docker rm
More: https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes