How to make docker-compose work on M1 chip?
Asked Answered
M

2

14

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

Miley answered 25/10, 2021 at 13:23 Comment(2)
Your physical hardware isn't x86_64; why are you trying to set the wrong architecture?Loss
@DavidMaze it was advised in answer for this question btw. And I'm asking for the correct way for m1 archMiley
H
28

For me i added platform: linux/amd64.

Example:

version: "3.7"

services:
  search:
    platform: linux/amd64
    build:
      context: .
      dockerfile: Dockerfile.kubectl
Horrid answered 5/1, 2022 at 14:25 Comment(0)
D
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>
Drud answered 25/10, 2021 at 13:28 Comment(3)
Credits: https://mcmap.net/q/182688/-lib64-ld-linux-x86-64-so-2-no-such-file-or-directory-errorDrud
I have platform specified in docker-compose described in question and it is linux/x86_64. When i run my docker-compose with this platform i get such error: Error response from daemon: image with reference search was found but does not match the specified platform: wanted linux/amd64, actual: linux/arm64/v8 What is the right way to run docker-compose to avoid this?Miley
Please flag this question as a duplicate of the other, if they have the same answer.Loss

© 2022 - 2024 — McMap. All rights reserved.