0

I'm attempting to deploy a .net Application to Digital Ocean Kubernetes, put to no luck. When creating a simple web.yml deployment I am seeing the status log return ERROR and when running logs on the pod I see the following:

standard_init_linux.go:228: exec user process caused: exec format error

I have done some research around this error, and it seems that my architecture is mismatched. However, I'm 99.999% my architecture my Digital Ocean cluster is AMD, and the image I have built from the following Dockerfile is linux/arm64/v8.

I have the following Dockerfile:

# syntax=docker/dockerfile:1
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app 

# copy everything else and build app
COPY . .

RUN dotnet restore 

WORKDIR /app/ASCOM.Alpaca.Simulators
RUN dotnet publish -c Release -o out 

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
WORKDIR /app 

COPY --from=build /app/ASCOM.Alpaca.Simulators/out ./

Which I build and push to my docker hub via the standard docker compose build command.

I've looked a few few online references around how to potentially build this as AMD, or other, but I currently can't seem to reference a working potential solution.

I have the following docker-compose.yaml file:

version: "3.9"
services:
    web:
        build: .
        ports:
            - "80:32323"
        image: observerly/ascom-alpaca:latest
        command: ["dotnet", "ascom.alpaca.simulators.dll", "--urls=http://*:32323"]

I have seen topics around buildkit ... but I haven't really been able to understand the exact steps I need to take to build a different arch image for .net core.

I've run docker manifest inspect --verbose mcr.microsoft.com/dotnet/aspnet:6.0 which gives me the hint that AMD64 can be used:

"platform": {
    "architecture": "amd64",
    "os": "linux"
}

Any pro-tips would be amazing!

Micheal J. Roberts
  • 3,735
  • 4
  • 37
  • 76
  • If your image is linux/arm64/v8 (Mac M1) then it won't run on an AMD64 machine. – Hans Kilian Feb 24 '22 at 12:41
  • Hi Hans, so yes I get that this is the case. But I am wondering ... is there a way to build the dotnet image for a different architecture ... ? I have also tried 6.0-focal-amd64 for both sdk and dotnet but it gives me another random cryptic error... `failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c dotnet restore]: exit code: 139` – Micheal J. Roberts Feb 24 '22 at 12:44
  • I don't have a Mac, so I have no 1st hand experience, but try adding `--platform linux/amd64` on your `docker build` command – Hans Kilian Feb 24 '22 at 12:49
  • It looks like the solution might be via build ... https://blog.jaimyn.dev/how-to-build-multi-architecture-docker-images-on-an-m1-mac/ – Micheal J. Roberts Feb 24 '22 at 12:50
  • Sanity Check. (for you and for ME!). If the "platform architecture" matches on the sdk-image and the run-time-image.....doesn't that absolve you from the platform the K8 engine is installed on? maybe i'm being naive). As a hint, you could try debugging it out with minikube...before moving to the big-brothers. (Another way to put it, there's a difference between BUILDING a (new/piggyback image) vs USING established images. – granadaCoder Feb 24 '22 at 13:07
  • You can build cross-architecture with `buildx` (buildx is still in experimental stage, FYI). `docker buildx build --platform linux/amd64` for example. If this does not work, you can explicitly set dotnet image to use amd64 with `6.0-alpine-amd64` tag. –  Feb 25 '22 at 09:28

0 Answers0