Skip to content

[docker] Upgrade labs for cross-platform compatibility #508

@denik1981

Description

@denik1981

Describe the bug
When running examples/labs for the docker workshop locally people will find that some Dockerfiles won't build because they are targeting a specific arch different than the one the user is running the docker daemon.

I have seen a lot of Dockerfiles targetting, for eg, alpine:3.5 as the base image which is amd64 specific
If you run the build in an arm64v8 arch like myself which I have a Mac you might encounter this compatibility error.

To Reproduce
Steps to reproduce the behavior:

  1. Check that your running architecture differs from amd64
uname -m // arm64
  1. Try to build this testing Dockerfile
FROM alpine:3.5
CMD ["/bin/echo", "Works!"]
docker build -t try .
  1. See error
[+] Building 1.1s (3/3) FINISHED                                                                                  docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                              0.0s
 => => transferring dockerfile: 79B                                                                                               0.0s
 => [internal] load .dockerignore                                                                                                 0.0s
 => => transferring context: 2B                                                                                                   0.0s
 => ERROR [internal] load metadata for docker.io/library/alpine:3.5                                                               1.0s
------
 > [internal] load metadata for docker.io/library/alpine:3.5:
------
Dockerfile:1
--------------------
   1 | >>> FROM alpine:3.5
   2 |     CMD ["/bin/echo","Works!"]
--------------------
ERROR: failed to solve: alpine:3.5: no match for platform in manifest sha256:66952b313e51c3bd1987d7c4ddf5dba9bc0fb6e524eed2448fa660246b3e76ec: not found

Expected behavior
Build should be possible with more archs different than amd64.
There are some images that are multi-arch in the alpine official repo for the case and for the many other OS base-image repos that are used in the workshop.

Proposed solution

For alpine references please use instead apline:3 that targets to alpine:latest which is compatible with 386, amd64 and arm architectures. Proves to work well in my arm64v8 Mac.

Desktop (please complete the following information):

  • OS: uname -a
    Darwin Demians-MacBook-Pro.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 arm64

Kudos to the creator and contributors of this wonderful workshop!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions