Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pull docker image for different architecture

Tags:

docker

I have an air gapped system that I'm running some docker containers on. I'm trying to get some images on it however the system is a different architecture than what I'm running. For a few images (like GCC) I was able to just say docker pull repo/gcc and that worked fine, however for some reason when I try to do docker pull repo/python I get:

Using default tag: latest
latest: Pulling from repo/python
no matching manifest for linux/amd64 in the manifest list entries

Is there a way to specify the architecture in my pull request?

like image 543
AndyReifman Avatar asked Feb 07 '20 13:02

AndyReifman


People also ask

Can Docker run on different architecture?

Docker Desktop provides binfmt_misc multi-architecture support, which means you can run containers for different Linux architectures such as arm , mips , ppc64le , and even s390x . This does not require any special configuration in the container itself as it uses qemu-static from the Docker for Mac VM.

How do I create a Docker image for multiple architectures?

You can build a multi-arch image by creating the individual images for each architecture, pushing them to Docker Hub, and entering docker manifest to combine them within a tagged manifest list. You can then push the manifest list to Docker Hub.

Can you pull multiple Docker images?

By default, docker pull pulls a single image from the registry. A repository can contain multiple images.

Is Docker image architecture dependent?

Docker images obviously contain processor specific instructions, which makes them architecture dependent.


3 Answers

With the latest docker, you can specify platform when you're pulling

docker pull --platform linux/arm64 alpine:latest
like image 180
stefan2718 Avatar answered Oct 20 '22 06:10

stefan2718


Docker from version 20.10.0+ (released on 2020-12-08) supports explicit definition of the platform via --platform tag, e.g.:

docker pull --platform linux/arm64 repo/python

Of course, source must contain an image for the requested platform.

Answer for Docker versions before 20.10.0:

To answer question from the title: you can pull image by digest.

Example: list all supported architectures (manifest):

$ docker manifest inspect ckulka/multi-arch-example
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 2200,
         "digest": "sha256:6eaeab9bf8270ce32fc974c36a15d0bac4fb6f6cd11a0736137c4248091b3646",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 2413,
         "digest": "sha256:f02e0fd2918a894ecd49d67b802c22082dc3c6424f6566e1753a83ba833b0993",
         "platform": {
            "architecture": "arm",
            "os": "linux",
            "variant": "v5"
         }
      },
...

And then pull by digest, e.g. arm arch (pulled on linux machine):

$  docker pull ckulka/multi-arch-example@sha256:f02e0fd2918a894ecd49d67b802c22082dc3c6424f6566e1753a83ba833b0993

But you can't run all architectures, so it can be useless when you pull image for different architecture.

like image 37
Jan Garaj Avatar answered Oct 20 '22 05:10

Jan Garaj


If the image is not multi-arch, you cant unless you emulate your architecture to be of the target architecture of the manifest.

like image 2
Ali Ben Zarrouk Avatar answered Oct 20 '22 05:10

Ali Ben Zarrouk