Hi,
I am using macbook M1 and I got the following error when try executing the command below in docker:
docker build -t $APP_NAME:$CI_PIPELINE_IID-amd64 .
error:
standard_init_linux.go:228: exec user process caused: exec format error
I google and realize that I got to use platform amd/64. Then i performed the cmd below and it works:
docker buildx build --platform=linux/amd64 -t $APP_NAME:$CI_PIPELINE_IID-amd64 .
Again, the command above I tested in my terminal worked successfully then I try to copy into .gitlab.ci.yml. However, it returns me error below:
unknown flag: --platform
The details:
- Developer: Macbook M1
- Container: ECR
- Server: ECS
The content in .gitlab.ci.yml:
variables:
DOCKER_REGISTRY: x
AWS_DEFAULT_REGION: x
APP_NAME: sample-nodejs-app
DOCKER_HOST: tcp://docker:2375publish:
image:
name: amazon/aws-cli
entrypoint: [“”]
services:
- docker:dind
before_script:
- amazon-linux-extras install docker
- aws --version
- docker --version
script:
- aws ecr get-login-password | docker login --username AWS --password-stdin $DOCKER_REGISTRY
- docker build --platform linux/amd64 -t $APP_NAME:$CI_PIPELINE_IID .
- docker tag $APP_NAME:$CI_PIPELINE_IID $DOCKER_REGISTRY/$APP_NAME:$CI_PIPELINE_IID
- docker push $DOCKER_REGISTRY/$APP_NAME:$CI_PIPELINE_IID
Some output from pipeline:
$ aws --version
aws-cli/2.7.27 Python/3.9.11 Linux/5.4.109+ docker/x86_64.amzn.2 prompt/off$ docker --version
Docker version 20.10.17, build 100c701
aws ecr get-login-password | docker login --username AWS --password-stdin $DOCKER_REGISTRY
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See docker login | Docker Docs
Login Succeeded
$ docker buildx build --platform linux/amd64 --push -t $DOCKER_REGISTRY/$APP_NAME:$CI_PIPELINE_IID .
unknown flag: --platform
See ‘docker --help’.
Usage: docker [OPTIONS] COMMAND
May I know is it due to pipeline not compatible? Is there any solution?