user8234856
user8234856

Reputation:

How to run Dockerfile at Silicon Mac M1 from Intel Mac

I'm not a native speaker of English, but I want to ask a question on Stack Overflow. and I am a beginner at Docker.

I am trying to set up the development environment at Silicon Mac M1 from Intel mac.

#!/bin/sh
set -e
. ./env.list
# Build Docker image
# docker pull store/ibmcorp/db2_developer_c:11.1.4.4-x86_64
docker build -t ${REPOSITORY}:${TAG} .

# DOCKERFILE
FROM store/ibmcorp/db2_developer_c:11.1.4.4-x86_64
RUN yum -y update && yum clean all
RUN curl ftp://ftp.pbone.net/mirror/vault.centos.org/7.8.2003/os/x86_64/Packages/glibc-common-2.17-307.el7.1.x86_64.rpm > /tmp/glibc-common.rpm
RUN rm -f /etc/localtime
RUN mkdir /var/custom

and I got errors like below

Step 2/30 : RUN yum -y update && yum clean all
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

I already add --platform linux/amd64 another docker run command

#!/bin/bash
. ./env.list
docker rm -f api-db
docker run --name api-db -h db2server --restart=always --detach --privileged=true -p 50000:50000 -p 55000:55000 --platform linux/amd64 --env-file env.list sample-app:v1.0

what should I do for a dockerfile?

Thank you so much for reading.

Have a good day! :)

Upvotes: 3

Views: 10168

Answers (1)

jordanvrtanoski
jordanvrtanoski

Reputation: 5537

Apple M1 is arm64v8 instruction set processor, so you can not run amd64 (X86_64) on it without emulation. In general, Docker has the ability to emulate other architectures if the emulation based on bitfmt is set up (and on maxOS with intel CPU it's already set-up), however the emulation for amd64 on M1 is not stable yet. This means that for some period of time you will be restricted to 'arm64' images.

To fetch the proper image for you architecture during the build you need to add the following.

FROM --platform linux/arm64 <image name>

You need to check if there are images for db2 development environment for arm by doing

docker pull --platform linux/arm64 store/ibmcorp/db2_developer_c

Upvotes: 5

Related Questions