Part of my dockerfile:
FROM node:18-alpine as installer
WORKDIR /app
ENV NODE_ENV=development
COPY package*.json .
COPY tsconfig.json .
RUN npm ci
FROM node:18-alpine as builder
WORKDIR /app
ENV NODE_ENV=development
COPY --from=installer /app/ .
COPY src/ ./src/
RUN npm run build
Part of my docker-compose.yml
version: '3.8'
services:
function-app:
container_name: function-app
restart: always
depends_on:
- mongo
build: .
environment:
- DB_HOST=mongo:27017
- DB_USERNAME=qq
- DB_PASSWORD=qq
ports:
- 1337:80
volumes:
- ./dist/:/home/site/wwwroot/
This works for all my colleagues.
I’m getting this:
I tried changing to FROM --platform=linux/amd64 node:18-alpine as installer
No effect.
I’m the only one on the team running an Apple M1 computer. Maybe thats the problem?
Any suggestions what might be the problem and how to solve it?
Update
I reinstalled docker.
Got a new error: "Function not implemented"
Which pointed me here: https://github.com/Azure/azure-functions-core-tools/issues/2901
Summary of that thread: There currently is no solution for M1.
So we moved away from docker on the project (not the most popular team member at the moment).
Thanks for all answers!
3
Answers
What output has
docker info
command? Maybe you should install docker via brew:brew install --cask docker
In my original answer, posted below, I tried to help you create a node image capable of running for Apple M1 arm64 architecture, but the reason of the problem could be another.
You included the
installer
andbuilder
images you are using in your Docker file but, according to the error you provided, you seem to be using the Azure Functions for node docker image.If that is the case, it seems that, at the moment, as you can see in this or this other Github issues, this image doesn’t support the arm64 architecture yet. You can verify it as well reviewing the list of the different tags in Docker Hub.
You can try building your own images as suggested in this post, but I don’t know if it is a possible solution.
I think there shouldn’t be any problem in building your image for amd64 using Apple M1 and the approach suggested in my previous answer below or a similar one; the result image should be able to be run in linux amd64 without further problem. The only problem is try running it in arm64.
To provide context, my original answer follows.
My first words should be that I don’t have the opportunity to use an Apple M1 computer, so the following answer is based only on assumptions and not on facts as I would like: please, take that only as general guidance, background information, and not as a true answer, because I am unsure if it would work.
The error indicates that your Functions runtime could be started appropriately.
It could be motivated by different things and the use of an unsupported version of
node
due to the use of the different chipset architecture of Apple Silicon M1 could be one of them.It may have no effect, but you could try building explicitly your image for a different architecture.
The process of building multi-platform images is very well described in the Docker documentation.
That documentation provides a getting started section that indicates the different steps that need to be carried out in order to setup the build system.
Basically, as a first step, you probably will need to create a new builder based on the docker container driver:
As stated in the docs:
The created builder should appear in the list of available ones. You can verify it issuing the following command:
As explained in the aforementioned Docker documentation, depending on your setup, it may be necessary to install the following for providing support for additional platforms:
Please, consider read this related SO question.
If everything is fine, you should be able to build your image with something like the following from the directory:
The above command assumes you are not using a registry and that the image will be stored locally: it will work only if you provide a single platform destination.
Please, note I used
linux/arm64
and notlinux/amd64
: honestly I am a bit confused about that, but I think you should use the platform in which your application should be run into. This great article from the docker blog, in general, provides one of the better explanations I have ever read about how docker multi-platform builds work; particularly, it provides great guidance about the different variables you could use to make yourDockerfile
portable across different platforms.The generated image could be used later in docker-compose:
I was digging into the issue when I saw your question and it "seems" that docker-compose is unable to build the image as described: that is the reason why I used the
docker buildx
command directly. Please, consider review this SO question and the following Docker Desktop documentation regarding this issue.To solve this problem, You can try change the Dockerfile to:
Explanation: The problem was that the node:18-alpine image is not available for the Apple M1 architecture. The solution was to use the –platform=linux/amd64 flag to force the image to be built for the x86 architecture.