5

hi following are my docker file commands

ARG debianVersion=10.2
FROM debian:${debianVersion}
ARG user=jenkins
ARG group=jenkins
ARG uid=1000
ARG gid=1000
ARG AGENT_WORKDIR=/home/${user}/agent
USER root
RUN apt-get update
RUN groupadd -g ${gid} ${group}
RUN useradd -c "Jenkins user" -d /home/${user} -u ${uid} -g ${gid} -m ${user}

I am using rancher desktop on mac m1 chip.

On executing following command I a getting error

docker build -t test --platform linux/x86_64 .

Error message is as follows

[Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
---> Running in 7778b2303192
-c: 0: Can't open apt-get update
The command '/bin/sh -c apt-get update' returned a non-zero code: 127

Found that none of the shell commands are working getting error a non-zero code: 127 how to fix this?

Using rancher version 1.5.0 Using container runtime dockerd(moby) Using Kubernetes version v1.21.14

amodkanthe
  • 4,345
  • 6
  • 36
  • 77
  • What is the base image (the image's `FROM` line)? Are you certain you have an official copy of it; does something like `docker pull ubuntu:20.04` to re-download it from Docker Hub make any difference? – David Maze Aug 01 '22 at 18:48
  • hi updated question using FROM debian:${debianVersion} – amodkanthe Aug 01 '22 at 18:55

3 Answers3

1

Downgrade to Rancher Desktop 1.4.1.

This works but if downgrading is not an option there are workarounds on the Rancher Desktop Issues site for similar problems like this: qemu workaround

As a temporary workaround, as root in the VM:

Create /etc/conf.d/qemu-binfmt, with contents binfmt_flags="POCF"
Run rc-update --update
Run rc-service qemu-binfmt restart

Easy way to connect to the VM and run those commands is (source):

docker run -it --rm --privileged --pid=host justincormack/nsenter1
wor
  • 343
  • 2
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 07 '22 at 10:18
0

Dockerfile:

…
FROM --platform=linux/arm64 debian:${debianVersion}
…

Build command:

docker build -t test --platform linux/arm64 .
Slava Kuravsky
  • 2,702
  • 10
  • 16
0

As far as I understand it dockerd runtime can only emulate other platform types (in the above case --platform=linux/amd64) on the m1 chip macs using Docker Desktop.

Try using the built in nerdctl that comes packaged with Rancher Desktop:

nerdctl build -t test --platform linux/amd64 .
nerdctl build -t test --platform linux/x86_64 .

N.B. I have found that even with emulation, some --platform linux/x86_64 (linux/amd64) images still cannot be built, recently experienced that with official selenium set, but had no problem with wso2 & mailcatcher images

djmonki
  • 3,020
  • 7
  • 18
  • tried this not working got same error – amodkanthe Aug 04 '22 at 08:20
  • Unfortunately, it just maybe the container, some just cannot work with emulation. As a test, see how you fair with these under emulation: ```docker run --platform linux/x86_64 centos:8``` & ```docker run --platform linux/x86_64 ruby:alpine``` – djmonki Aug 04 '22 at 09:05
  • I have just built your image with Docker Desktop and got the container running. I am on Monterey 12.2.1. Wonder if Rancher Desktop is the issue ? Both docker build and run commands used --platform linux/x86_64. – djmonki Aug 05 '22 at 16:10