'How to make docker-compose work on M1 chip?

I'm new to m1 macbook and face an issue with running my docker-compose which looks like this:

version: "3.7"

services:
  search:
    platform: linux/x86_64
    build:
      context: .
      dockerfile: Dockerfile.kubectl
  

And the Dockerfile:

FROM ubuntu:latest

RUN apt-get update && apt-get install -y apt-transport-https curl gnupg2 unzip
RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
RUN echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list
RUN apt-get update && apt-get install -y kubectl

RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && rm awscliv2.zip
RUN ./aws/install

After running it I get such an error:

2021-09-30T13:24:52.816038712Z /lib64/ld-linux-x86-64.so.2: No such file or directory

What exactly are steps to fix this? My Docker version is 4.1.1



Solution 1:[1]

For me i added platform: linux/amd64.

Example:

version: "3.7"

services:
  search:
    platform: linux/amd64
    build:
      context: .
      dockerfile: Dockerfile.kubectl

Solution 2:[2]

I believe the image you are running is for x86_64 platform, hence it tries to find x86-64.so, but you are on an arm machine, so it does not work. You can either install the image for arm64 or try running the command like this:

docker run --platform linux/x86_64 <image>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MrBowie20
Solution 2 yum