Saturday 9 May 2020

How to delete a docker image?

‘docker rmi {imageName}’ or ‘docker rmi {imageId}’ is used to remove an image.

$docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
postgres            latest              79db2bf18b4a        2 months ago        312MB
busybox             latest              e4db68de4ff2        2 months ago        1.22MB
jboss/wildfly       latest              4e440230e01d        2 months ago        748MB
tagsapp             1                   17ff919cfdbd        4 months ago        88.9MB
tagsapp             2                   17ff919cfdbd        4 months ago        88.9MB
tagsapp             latest              a1868b148d8d        4 months ago        88.9MB
ubuntu              latest              94e814e2efa8        5 months ago        88.9MB
jenkins             latest              cd14cecfdb3a        13 months ago       696MB

Let’s remove the image busybox using name.
$docker rmi busybox
Untagged: busybox:latest
Untagged: busybox@sha256:7a4d4ed96e15d6a3fe8bfedb88e95b153b93e230a96906910d57fc4a13210160
Deleted: sha256:e4db68de4ff27c2adfea0c54bbb73a61a42f5b667c326de4d7d5b19ab71c6a3b
Deleted: sha256:6194458b07fcf01f1483d96cd6c34302ffff7f382bb151a6d023c4e80ba3050a
$
$
$docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
postgres            latest              79db2bf18b4a        2 months ago        312MB
jboss/wildfly       latest              4e440230e01d        2 months ago        748MB
tagsapp             1                   17ff919cfdbd        4 months ago        88.9MB
tagsapp             2                   17ff919cfdbd        4 months ago        88.9MB
tagsapp             latest              a1868b148d8d        4 months ago        88.9MB
ubuntu              latest              94e814e2efa8        5 months ago        88.9MB
jenkins             latest              cd14cecfdb3a        13 months ago       696MB

Let’s remove postgres image using id.

$docker rmi 79db2bf18b4a
Untagged: postgres:latest
Untagged: postgres@sha256:fb0ff33f663bcb5bc4962cac44ccffb57f4523c1fc2a17b0504db1c07c1d2666
Deleted: sha256:79db2bf18b4a48fdc4f89b5ca84490ff842d0b45d8dc5e7e26927c6c7ae5e7e5
Deleted: sha256:c82a8733a1f099314f7b9709c75f493405613996535831422d4e2c2938e607a7
Deleted: sha256:174f239b700ffbf93906b00df58a66c15d6dd213d49391f99fbab7e9b7e9be75
Deleted: sha256:467439ba0a3fef8dc47901cb8ceb3136c9d9bbad759a307187e44a96ec1ef77b
Deleted: sha256:845279ff221d47eec7f400fff8803f5c2474f75118dc88e30d49ca2f66aef942
Deleted: sha256:1e5fa5a8e5cbe62531a6b9a0cfbbb19ef6ac1b2f08d3922b71feda94092a310c
Deleted: sha256:4b439fe1793670eb57213c1d3f8e1bfbcae89cc6f68b8b84d085f362aeb09ded
Deleted: sha256:cfac349bd70ab8736344af4d893fdb6cb339447282d465f4bdda80bce05863aa
Deleted: sha256:dae9c54767816fa8bdfb009181f19f5a0113e3c5684dacdc410cf38039e4d8d6
Deleted: sha256:5e0556d2cf6fc334e058bed3813fae21d0eb25b0da3a77f6080418055d5cd414
Deleted: sha256:1533bc51c26b7f13702b71d95e4949927e4f2f37632a77d9d6c2c9ded93495ce
Deleted: sha256:83b55c6a2862401e578cce4865006ede988b3538576600b2087e89912560bdbb
Deleted: sha256:3a42b7f34a8bec13305bd693cbe4522822707faadb5c79c8af1ec652aa0a3ea3
Deleted: sha256:bf6a0011068b5cf64a5dbca2de889006f2117bd0cfd828106012e4b9328d0fef
Deleted: sha256:cf5b3c6798f77b1f78bf4e297b27cfa5b6caa982f04caeb5de7d13c255fd7a1e
$
$
$docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
jboss/wildfly       latest              4e440230e01d        2 months ago        748MB
tagsapp             1                   17ff919cfdbd        4 months ago        88.9MB
tagsapp             2                   17ff919cfdbd        4 months ago        88.9MB
tagsapp             latest              a1868b148d8d        4 months ago        88.9MB
ubuntu              latest              94e814e2efa8        5 months ago        88.9MB
jenkins             latest              cd14cecfdb3a        13 months ago       696MB

Note
You must stop and delete all the dependent containers to remove an image.

Previous                                                    Next                                                    Home

No comments:

Post a Comment