@@ -9,10 +9,11 @@ Remove one or more images
99
1010### Options
1111
12- | Name | Type | Default | Description |
13- | :----------------| :-------| :--------| :-------------------------------|
14- | ` -f ` , ` --force ` | ` bool ` | | Force removal of the image |
15- | ` --no-prune ` | ` bool ` | | Do not delete untagged parents |
12+ | Name | Type | Default | Description |
13+ | :--------------------------| :--------------| :--------| :-------------------------------------------------------------------------------------------------|
14+ | ` -f ` , ` --force ` | ` bool ` | | Force removal of the image |
15+ | ` --no-prune ` | ` bool ` | | Do not delete untagged parents |
16+ | [ ` --platform ` ] ( #platform ) | ` stringSlice ` | | Remove only the given platform variant. Formatted as ` os[/arch[/variant]] ` (e.g., ` linux/amd64 ` ) |
1617
1718
1819<!-- -MARKER_GEN_END-->
@@ -105,3 +106,75 @@ Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
105106Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2
106107Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b
107108```
109+
110+
111+ ### <a name =" platform " ></a > Remove a specific platform (` --platform ` )
112+
113+ The ` --platform ` option allows you to specify which platform variants of the
114+ image to remove. By default, ` docker image remove ` removes all platform variants
115+ that are present. Use the ` --platform ` option to specify which platform variant
116+ of the image to remove.
117+
118+ Removing a specific platform removes the image from all images that reference
119+ the same content, and requires the ` --force ` option to be used. Omitting the
120+ ` --force ` option produces a warning, and the remove is canceled:
121+
122+ ``` console
123+ $ docker image rm --platform=linux/amd64 alpine
124+ Error response from daemon: Content will be removed from all images referencing this variant. Use —-force to force delete.
125+ ```
126+
127+
128+ The platform option takes the ` os[/arch[/variant]] ` format; for example,
129+ ` linux/amd64 ` or ` linux/arm64/v8 ` . Architecture and variant are optional,
130+ and default to the daemon's native architecture if omitted.
131+
132+ You can pass multiple platforms either by passing the ` --platform ` flag
133+ multiple times, or by passing a comma-separated list of platforms to remove.
134+ The following uses of this option are equivalent;
135+
136+ ``` console
137+ $ docker image rm --plaform linux/amd64 --platform linux/ppc64le myimage
138+ $ docker image rm --plaform linux/amd64,linux/ppc64le myimage
139+ ```
140+
141+ The following example removes the ` linux/amd64 ` and ` linux/ppc64le ` variants
142+ of an ` alpine ` image that contains multiple platform variants in the image
143+ cache:
144+
145+ ``` console
146+ $ docker image ls --tree alpine
147+
148+ IMAGE ID DISK USAGE CONTENT SIZE EXTRA
149+ alpine:latest a8560b36e8b8 37.8MB 11.2MB U
150+ ├─ linux/amd64 1c4eef651f65 12.1MB 3.64MB U
151+ ├─ linux/arm/v6 903bfe2ae994 0B 0B
152+ ├─ linux/arm/v7 9c2d245b3c01 0B 0B
153+ ├─ linux/arm64/v8 757d680068d7 12.8MB 3.99MB
154+ ├─ linux/386 2436f2b3b7d2 0B 0B
155+ ├─ linux/ppc64le 9ed53fd3b831 12.8MB 3.58MB
156+ ├─ linux/riscv64 1de5eb4a9a67 0B 0B
157+ └─ linux/s390x fe0dcdd1f783 0B 0B
158+
159+ $ docker image --platform=linux/amd64,linux/ppc64le --force alpine
160+ Deleted: sha256:1c4eef651f65e2f7daee7ee785882ac164b02b78fb74503052a26dc061c90474
161+ Deleted: sha256:9ed53fd3b83120f78b33685d930ce9bf5aa481f6e2d165c42cbbddbeaa196f6f
162+ ```
163+
164+ After the command completes, the given variants of the ` alpine ` image are removed
165+ from the image cache:
166+
167+ ``` console
168+ $ docker image ls --tree alpine
169+
170+ IMAGE ID DISK USAGE CONTENT SIZE EXTRA
171+ alpine:latest a8560b36e8b8 12.8MB 3.99MB
172+ ├─ linux/amd64 1c4eef651f65 0B 0B
173+ ├─ linux/arm/v6 903bfe2ae994 0B 0B
174+ ├─ linux/arm/v7 9c2d245b3c01 0B 0B
175+ ├─ linux/arm64/v8 757d680068d7 12.8MB 3.99MB
176+ ├─ linux/386 2436f2b3b7d2 0B 0B
177+ ├─ linux/ppc64le 9ed53fd3b831 0B 0B
178+ ├─ linux/riscv64 1de5eb4a9a67 0B 0B
179+ └─ linux/s390x fe0dcdd1f783 0B 0B
180+ ```
0 commit comments