How to delete unused images and containers Docker?

Learn a little bit of Docker as a replacement for Vagrant. Use under Windows 10 x64.

If you enter the command docker image ls-a I get here is such a huge list of images:
REPOSITORY TAG IMAGE ID CREATED SIZE
compressor latest e7bce9666889 10 days ago 749MB
<none> <none> 1f1f1aa4ae2f 10 days ago 749MB
<none> <none> 3bb11dab29e3 10 days ago 749MB
<none> <none> 9ba4f9c83e1d 10 days ago 739MB
<none> <none> c5e434998a55 10 days ago 733MB
<none> <none> 63ed6e76dd99 10 days ago 737MB
<none> <none> ee99372c449f 10 days ago 765MB
<none> <none> 383a61e13c20 10 days ago 737MB
<none> <none> e9190eaef8e6 10 days ago 733MB
<none> <none> 0cbc5aa5ef4d 10 days ago 749MB
<none> <none> 787250f91fef 10 days ago 749MB
<none> <none> 8a6e760211f9 10 days ago 749MB
<none> <none> 148153f129c5 10 days ago 739MB
<none> <none> 2de315c41c64 10 days ago 737MB
<none> <none> 1717e3c3bcc1 10 days ago 749MB
<none> <none> d56ede6c805e 10 days ago 749MB
<none> <none> 8cbc67298b2d 10 days ago 749MB
<none> <none> bff8e8f683c4 10 days ago 739MB
<none> <none> 623fb0ff2dcb 10 days ago 737MB
<none> <none> 6571e073391f 10 days ago 733MB
<none> <none> f5b87e8e05e1 10 days ago 758MB
<none> <none> 6ae3c4d8424d 10 days ago 758MB
<none> <none> dca137070f2a 10 days ago 749MB
<none> <none> 07674f826bc4 10 days ago 737MB
<none> <none> 300507774fcb 10 days ago 733MB
<none> <none> 4578d80529d1 10 days ago 737MB
<none> <none> 4fde50fc0a2e 10 days ago 733MB
<none> <none> d313e0599cff 10 days ago 273MB
<none> <none> 0839508746fb 10 days ago 269MB
<none> <none> af2b258db005 10 days ago 273MB
<none> <none> 82fc987fc158 10 days ago 269MB
<none> <none> 1442906cd12f 11 days ago 269MB
mariadb latest 7fcf8c1a96d2 4 weeks ago 397MB
<none> <none> 1a34fad76b34 4 weeks ago 733MB
d4w/nsenter latest 9e4f13a0901e 14 months ago 83.8 kB</none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none></none>


Also have a whole bunch of containers:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cf61b9666ef6 ee99372c449f "/bin/sh -c 'go-wr..." 10 days ago Exited (2) 10 days ago stoic_turing
b808be02b803 8a6e760211f9 "/bin/sh -c compre..." 10 days ago Exited (137) 10 days ago musing_yonath
0bc12515d24a d56ede6c805e "-name compressor," Created 10 days ago 0.0.0.0:8080->8080/tcp keen_kalam
b1e823f64cd6 d56ede6c805e "-name compressor," Created 10 days ago 0.0.0.0:8080->8080/tcp kind_leakey
f358c4ff64f8 d56ede6c805e "compressor" 10 days ago Exited (2) 10 days ago unruffled_yonath
9c608db2fd75 d56ede6c805e "compressor" 10 days ago Exited (2) 10 days ago heuristic_babbage
2868050bbff0 d56ede6c805e "compressor" 10 days ago Created stoic_haibt
eae11f3a306f d56ede6c805e "compressor" 10 days ago Exited (2) 10 days ago mystifying_snyder
6a5bac45ae30 f5b87e8e05e1 bash 10 minutes ago Exited (130) 10 days ago mystifying_sammet
7158ed3fb444 f5b87e8e05e1 bash 10 minutes ago Exited (0) 10 days ago wonderful_ritchie
8fc1484a144b f5b87e8e05e1 bash 10 minutes ago Exited (0) 10 days ago tender_goodall
1cfa3d889681 f5b87e8e05e1 bash 10 minutes ago Exited (0) 10 days ago peaceful_jang
41b51ef4dbd7 d313e0599cff "/bin/sh -c 'go ge..." 10 days ago Exited (1) 10 days ago elastic_brattain
8ce92252a980 1a34fad76b34 bash 10 minutes ago Exited (0) 10 days ago sad_heisenberg
c491683d1d18 1a34fad76b34 bash 10 minutes ago Exited (0) 10 days ago trusting_mestorf
ed4225d47dd5 1a34fad76b34 bash 10 minutes ago Exited (0) 10 days ago angry_boyd
9f813dcb7cfe c844795fa93c "/bin/sh -c 'go ge..." 10 days ago Exited (2) 10 days ago stupefied_brown
04b16547b6fc mariadb:latest "docker-entrypoint..." 3 weeks ago Exited (0) 16 hours ago db


From all this, I only use the container named db, collected from the image mariadb:latest. All the rest of my samples to create a container with Golang app.

The following types of questions:
1. How to delete all unnecessary images?
2. The sum size of all images is the used space on the disk for images? Or if the image A (size 6MB) uses the image of B (500MB), then the image in the list with size 506 MB, but actually takes only 6 MB?
3. If I have collected a container from the image, can I delete the image from disk?
June 10th 19 at 16:58
1 answer
June 10th 19 at 17:00
As the decision to launch the desired containers, and then docker system prune -a. Remove all unused containers and images.

Read more: https://docs.docker.com/engine/reference/commandli...

Find more questions by tags Docker