How to have Docker multi-architecture setup
Fix Apple M1 chip issue on building docker containers
You have an M1 chip, so keep reading. I am going to share my approach about having multiple architectures on both M1 and Linux/AMD64 architecture for building images with some simple setups.
Let say you are using some CICD to deploy to the AWS. Probably it will work on the pipeline because it will only need to pull and create new images to push but when it comes to the running container on AWS/ECS/EKS it will not work because you set everything regarding your M1 chip, because you are testing it on your local.
Probably you have searched for the Manifest and buildx command but i hate it to have different commands for every step.
To have multiple architectures for this kind of Docker Containers, I create docker-compose and set the platform in it.
Let's say we have this dockerfile
FROM ubuntu:20.04
RUN apt-get update -y && apt-get -y install tzdata
RUN echo "Europe/Amsterdam" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata
ENTRYPOINT ["tail", "-f", "/dev/null"]
and my docker-compose.yml file will be looked like this
version: '3.6'
services:
site:
build:
context: .
dockerfile: ./Dockerfile
platform: linux/x86_64
and that's all. You do not need to change your pipelines to build applications or run with docker buildx build command