How to use docker manifest rm command to delete manifest lists

DockerDockerBeginner
Practice Now

Introduction

In this lab, you will learn how to manage Docker manifest lists, which are essential for creating multi-architecture images. We will cover the process of creating a manifest list by combining images for different platforms, verifying its existence using the docker manifest inspect command, and finally, demonstrating how to delete a manifest list using the docker manifest rm command. This hands-on exercise will provide practical experience in handling manifest lists within your Docker workflow.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL docker(("Docker")) -.-> docker/ContainerOperationsGroup(["Container Operations"]) docker(("Docker")) -.-> docker/ImageOperationsGroup(["Image Operations"]) docker/ContainerOperationsGroup -.-> docker/rm("Remove Container") docker/ContainerOperationsGroup -.-> docker/inspect("Inspect Container") docker/ImageOperationsGroup -.-> docker/pull("Pull Image from Repository") docker/ImageOperationsGroup -.-> docker/rmi("Remove Image") subgraph Lab Skills docker/rm -.-> lab-555172{{"How to use docker manifest rm command to delete manifest lists"}} docker/inspect -.-> lab-555172{{"How to use docker manifest rm command to delete manifest lists"}} docker/pull -.-> lab-555172{{"How to use docker manifest rm command to delete manifest lists"}} docker/rmi -.-> lab-555172{{"How to use docker manifest rm command to delete manifest lists"}} end

Create a manifest list

In this step, we will learn how to create a manifest list in Docker. A manifest list is a list of image manifests, which allows you to use a single image name to refer to images for different architectures and operating systems. This is particularly useful for building multi-architecture images.

First, let's pull two different images that we will use to create our manifest list. We will use the alpine image for amd64 and arm64 architectures.

docker pull alpine:latest
docker pull --platform arm64 alpine:latest

The first command pulls the alpine:latest image for your current architecture (likely amd64). The second command explicitly pulls the alpine:latest image for the arm64 architecture.

Now, we can create the manifest list using the docker manifest create command. The syntax is docker manifest create TARGET_IMAGE SOURCE_IMAGE [SOURCE_IMAGE...]. We will create a manifest list named my-alpine:latest that includes the alpine:latest images for amd64 and arm64.

docker manifest create my-alpine:latest alpine:latest alpine:latest --amend alpine:latest --platform arm64

In this command:

  • my-alpine:latest is the name of the new manifest list we are creating.
  • alpine:latest is the first source image (for the default architecture).
  • --amend alpine:latest --platform arm64 adds the alpine:latest image for the arm64 platform to the manifest list.

After running this command, you have created a manifest list locally. However, it is not yet pushed to a registry. We will push it in a later step.

Verify the manifest list exists

In the previous step, we created a manifest list named my-alpine:latest. Now, we will verify that this manifest list was successfully created and exists locally.

We can use the docker manifest inspect command to view the details of a manifest list. This command will output the manifest list's content in JSON format if it exists.

docker manifest inspect my-alpine:latest

If the manifest list my-alpine:latest was created successfully, you will see a JSON output describing the manifest list, including the different images it references for various architectures. If the manifest list does not exist, the command will return an error.

The output will show information about the manifest list, such as the schema version, media type, and a list of manifests for each architecture included. You should see entries for both amd64 and arm64 architectures, confirming that the manifest list was created correctly with references to the images for those platforms.

Delete the manifest list

In the previous steps, we created and verified the existence of a manifest list named my-alpine:latest. Now, we will learn how to delete this manifest list.

To delete a manifest list, we use the docker manifest rm command followed by the name of the manifest list.

docker manifest rm my-alpine:latest

This command will remove the local reference to the manifest list my-alpine:latest. Note that this command only removes the manifest list itself, not the individual images that the manifest list references. The alpine:latest images for amd64 and arm64 that we pulled earlier will still remain on your system.

After executing the command, you should see output indicating that the manifest list has been untagged.

Verify the manifest list is deleted

In the previous step, we deleted the manifest list named my-alpine:latest. Now, we will verify that the manifest list has been successfully deleted and no longer exists locally.

We can attempt to inspect the manifest list again using the docker manifest inspect command. If the manifest list was successfully deleted, this command should return an error indicating that the manifest list is not found.

docker manifest inspect my-alpine:latest

When you run this command after deleting the manifest list, you should see an error message similar to no such manifest: docker.io/library/my-alpine:latest. This confirms that the manifest list has been removed from your local Docker environment.

Summary

In this lab, we learned how to create and manage Docker manifest lists. We began by pulling images for different architectures and then used the docker manifest create command to combine them into a single manifest list, demonstrating how to build multi-architecture images.

Following the creation, we verified the existence of the manifest list using the docker manifest inspect command. Finally, we learned how to delete the manifest list using the docker manifest rm command and confirmed its removal, covering the essential lifecycle management of manifest lists in Docker.