In this step, we will explore how to load a specific platform variant of a Docker image from an archive using the --platform
flag. This is particularly useful when an image archive contains variants for multiple architectures (e.g., linux/amd64
, linux/arm64
).
First, let's remove the hello-world
image again to start fresh.
docker rmi hello-world
You should see output confirming the image deletion.
Untagged: hello-world:latest
Deleted: sha256:...
Now, we will use the docker load
command with the --input
flag to specify the archive file and the --platform
flag to specify the desired platform. For this example, we will specify linux/amd64
, which is the architecture of the LabEx VM.
docker load --input ~/project/hello-world.tar --platform linux/amd64
The --platform
flag ensures that Docker only loads the image variant that matches the specified architecture and operating system. Even though the hello-world
image is very simple and likely doesn't have significant platform variations in its archive, this demonstrates the usage of the flag. You should see output indicating the layers are being loaded.
...
Loaded image: hello-world:latest
To confirm that the image has been loaded, list the Docker images.
docker images
The hello-world
image should be present in the list.
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest ... ... ...
Using the --platform
flag is important when working with multi-architecture image archives to ensure you load the correct variant for your environment.