EN
Docker - remove more than 1 docker image in single line
3 points
In this article we would like to show you how to remove more then 1 docker image in single command.
Quick solution:
xxxxxxxxxx
1
# remove 2 images in single line
2
$ docker rmi IMAGE_ID_1 && docker rmi IMAGE_ID_2
Practical example:
xxxxxxxxxx
1
# list all docker images
2
$ docker images
3
REPOSITORY TAG IMAGE ID CREATED SIZE
4
mysql latest e1d7dc9731da 2 weeks ago 544MB
5
docker/getting-started latest 1f32459ef038 2 months ago 26.8MB
6
openjdk 8-jdk-alpine a3562aa0b991 16 months ago 105MB
7
8
# remove 2 images in single line
9
$ docker rmi e1d7dc9731da && docker rmi 1f32459ef038
Explanation:
On above screenshot we can see that we executred 2 commands docker rmi IMAGE_ID in a single line with && operator.
After removal the docker images in this case will look like this:
xxxxxxxxxx
1
# list all docker images
2
$ docker images
3
REPOSITORY TAG IMAGE ID CREATED SIZE
4
openjdk 8-jdk-alpine a3562aa0b991 16 months ago 105MB