dockerlabs icon indicating copy to clipboard operation
dockerlabs copied to clipboard

[docker] Upgrade labs for cross-platform compatibility

Open denik1981 opened this issue 1 year ago • 3 comments

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!

denik1981 avatar Sep 24 '23 17:09 denik1981

@denik1981 I am going to fix those old alpine images. Also, we are planning to move these labs to mkdocs or Docusaurus for better structure layout.

ajeetraina avatar Sep 25 '23 03:09 ajeetraina

@denik1981 Would you like to raise PR updated with alpine:3.18 instead.

ajeetraina avatar Sep 30 '23 01:09 ajeetraina

Yes @denik1981 kindly raise a PR

Adesoji1 avatar Sep 30 '23 05:09 Adesoji1