Containers returns a list of containers using the image.
()
| 254 | |
| 255 | // Containers returns a list of containers using the image. |
| 256 | func (i *Image) Containers() ([]string, error) { |
| 257 | var containerIDs []string |
| 258 | containers, err := i.runtime.store.Containers() |
| 259 | if err != nil { |
| 260 | return nil, err |
| 261 | } |
| 262 | imageID := i.ID() |
| 263 | for i := range containers { |
| 264 | if containers[i].ImageID == imageID { |
| 265 | containerIDs = append(containerIDs, containers[i].ID) |
| 266 | } |
| 267 | } |
| 268 | return containerIDs, nil |
| 269 | } |
| 270 | |
| 271 | // removeContainers removes all containers using the image. |
| 272 | func (i *Image) removeContainers(options *RemoveImagesOptions) error { |