I started to learn how to work with Docker and I had this question. When I make "docker pull <image-name>" I usually pull the image from docker hub.
But images can have different versions that differ in OS and architecture. For example a python image has versions with linux and windows.
I'm wondering what image I'll get if I just do a "docker pull python" and how I can choose the OS and architecture myself.
I actually prefer to use linux images because it's lightweight and I don't want accidentally pull a windows image.
CodePudding user response:
I'm wondering what image I'll get if I just do a "docker pull python"
From "Leverage multi-CPU architecture support"
Most of the Docker Official Images on Docker Hub provide a variety of architectures.
For example, thebusyboximage supportsamd64,arm32v5,arm32v6,arm32v7,arm64v8,i386,ppc64le, ands390x.
When running this image on anx86_64/amd64machine, theamd64variant is pulled and run.
So it depends on the OS used when you do your docker pull.
and how I can choose the OS and architecture myself.
The same page adds:
You can also run images targeted for a different architecture on Docker Desktop.
You can run the images using the SHA tag, and verify the architecture.
For example, when you run the following on a macOS:docker run --rm docker.io/username/demo:latest@sha256:2b77acdfea5dc5baa489ffab2a0b4a387666d1d526490e31845eb64e3e73ed20 uname -maarch64
docker run --rm docker.io/username/demo:latest@sha256:723c22f366ae44e419d12706453a544ae92711ae52f510e226f6467d8228d191 uname -marmv71
In the above example, uname -m returns aarch64 and armv7l as expected, even when running the commands on a native macOS or Windows developer machine
CodePudding user response:
It's based on the host platform where docker is running. You can see this in docker info:
$ docker info --format '{{ .OSType }}/{{ .Architecture }}'
linux/x86_64
The code for this is in containerd and the OS and Arch are looked up slightly differently in go:
$ go env
GO111MODULE=""
GOARCH="amd64"
...
GOOS="linux"
...

