ShpilevojArsenij
ShpilevojArsenij

Reputation: 25

Docker image based on Playwright image runs on my Mac but don't run on Ubuntu server

When I run this image om my Mac with M1 chip, everything is OK. But when I try to run on server with Ubuntu, container stops with error "exec /bin/sh: exec format error"

FROM mcr.microsoft.com/playwright:v1.18.1-arm64
RUN apt-get -y update && apt-get -y upgrade
ADD build/libs/program.jar /tmp
WORKDIR /tmp
RUN apt-get -y install openjdk-11-jre-headless && apt-get clean;
CMD java -jar program.jar

This error displays on each first command RUN. Even if the command is like "RUN ls -la", I will get "/bin/sh -c ls -la returned a non-zero code: 1".

I tried to change SHELL["bin/bash","-c"] and image version but there was no effect.

If I use "FROM ubuntu", commands work, but I need exactly image for Playwright with browser dependencies.

Upvotes: 0

Views: 1714

Answers (1)

norbjd
norbjd

Reputation: 11237

You are building an image with ARM architecture (check with docker inspect <your_image> | grep "Archi"). This image cannot be executed on another architecture (probably amd64 for your Ubuntu server).

You should:

  • use an amd64 base image (mcr.microsoft.com/playwright:v1.18.1-arm64 => mcr.microsoft.com/playwright:v1.18.1-focal for example)
  • build your image with docker build --platform linux/amd64

Upvotes: 1

Related Questions