docker / for-linux

Docker Engine for Linux
https://docs.docker.com/engine/installation/
757 stars 86 forks source link

Docker 18.03.0-ce downloads different image from 18.06.1-ce - ARMv6 #463

Open fracz opened 6 years ago

fracz commented 6 years ago

Expected behavior

The following command

docker run -i -t php:7.0.27-apache /bin/bash

should work regardless of the Docker version on RaspberryPI Zero (ARMv6).

Actual behavior

The command above works on 18.03.0-ce but fails with segfault on 18.06.1-ce.

Additional environment details (AWS, VirtualBox, physical, etc.)

By inspecting the docker images followed by docker image inspect I found out, that the newer version of the Docker downloads another version of the container for some reason.

On 18.03.0-ce it is

sha256:7e11cf36f4f73660587f5c3a832c2c88fc4fda7db6858ba7235f4761216eff05
Created: 2018-02-15T23:19:54.344633286Z

On 18.06.1-ce it is

sha256:4dbb41f6ed5b41ed2102a7f8d23a17edc2b57e3274172af2fe1dd752a969c468
Created: 2018-02-15T15:27:10.501251405Z

They both claim they are built for arm architecture. However, the container that is downloaded with the newer Docker cannot be started. Logs of this container are empty. Trying to add apt-get install inside a Dockerfile based on the php:7.0.27-apache results in 139 error code, which I googled out to be a segfault/architecture problem.

I'm not sure if this is a problem with the image itself or with the Docker. I have tried another versions of php:*-apache and they behave the same way. After failed try on 18.06, I need to downgrade the docker to 18.03.0-ce, clean the images with docker system prune -a and then it starts to download the "correct" container that works as expected.

thaJeztah commented 6 years ago

Some changes were merged since 18.03; from the top of my head; https://github.com/moby/moby/pull/36816, and https://github.com/moby/moby/pull/37350

@arm64b @tonistiigi any ideas?

tonistiigi commented 6 years ago

The old behavior was to pick whatever arm image appeared in the manifest before. php:7.0.27-apache has v5 and v7 in that order so I think old version used v5. The new behavior matches the variant and if this fails, fall back to the old logic. There might be an issue in how containerd platform package detects the variant for this particular system(maybe it detects it as v7). cc @dmcgowan

fracz commented 6 years ago

Can I check how the containerd detects the architecture?

uname -m returns armv6l.

thaJeztah commented 6 years ago

I'm not too familiar with the containerd codebase, but based on some pull requests I noticed in this area, I think relevant code is in https://github.com/containerd/containerd/blob/db3c5afc6d61dc3bd1ac48a55156e58bf4557a45/platforms/platforms.go, https://github.com/containerd/containerd/blob/db3c5afc6d61dc3bd1ac48a55156e58bf4557a45/platforms/database.go

Some of those (possibly relevant) pull requests; https://github.com/containerd/containerd/pull/1403, https://github.com/containerd/containerd/pull/1575, https://github.com/containerd/containerd/pull/2416

tonistiigi commented 6 years ago

@fracz docker run --rm tonistiigi/whatsmyarch

If this binary does not run, try it with a platform specific digest.

amd64 sha256:cea5cbde2d5913551aaad68bfe7b99f3455daabea25cbab2e66ed56ebf00743f
arm64 sha256:7d25fde96b3b02c483b10bc286b3d17ec3990fc1eeea6edc2f750cf5c8e84058
arm/v5 sha256:fed0405b8fe6d026e7ddbff6935f52b2dfe917e6aa5911a51a0f7b95afd6a7ff
arm/v6 sha256:5fec0e7e099ec3b3155b7dd05f806f9d2f9efdc2ba4ca0f6e7a3fd6878f733b0
arm/v7 sha256:ddb320f97028082f4bd64f3d9d511e500675f89d0c1b18a170e82fb143f4c719
ppc64le sha256:a8de29ed1ecdf6b4ba4f3642c88b92783c2da8a27a3b4e31778afb65b8c18d53
s390x sha256:97d973bae4df85fbcda9c6b5e682b27296da7ffe530548329d05b8cf05dd2331

source https://gist.github.com/tonistiigi/1884472203c6c86d06ac4bd01c726519

edit: you can also use the digests to check what variants execute on your system

arm64b commented 6 years ago

ping @Pennyzct who is working on the multi-arch related stuff related with this, I am changing my tech direction...

Pennyzct commented 6 years ago

@weichen81

thaJeztah commented 6 years ago

I am changing my tech direction...

Thanks @arm64b - don't be a stranger πŸ‘ πŸ€—

arm64b commented 6 years ago

Thanks @arm64b - don't be a stranger πŸ‘ πŸ€—

Thanks @thaJeztah , hmmm, I've decided to leave Arm and join an internet company, so I will not be stranger, but the account name arm64b will be strangeπŸ€— πŸ™ πŸŽ‹ 🈹 πŸ˜‹ πŸ‘ πŸ₯‡ πŸ€—

Pennyzct commented 6 years ago

Hi~ @fracz the containerd check the /proc/cpuinfo to obtain the value of 'CPU Architecture'. if you have an armv6l chip, possibly you will get variant as 6. Like @tonistiigi said, if exact variant-matching couldn't work for you, docker will fall back to the old logic, which will choose the first entry for arm platform. So you could get the incompatible v7 image. after all, maybe docker engine should include the failure mode.😊