현제의 현재이야기

[Devops] [Error]docker-compose : Unsupported config option for services service: 'platform' 해결 본문

Infra

[Devops] [Error]docker-compose : Unsupported config option for services service: 'platform' 해결

현재의 현제 2023. 7. 19. 22:58

linux/amd64의 도커 이미지가 필요하나 m1 칩으로 이미지를 만들 시 linux/arm64로 만들어진다.

따라서, 원래 docker image build를 할 때, --platform ~~ 으로 amd64로 만들어야 하나 docker-compose 환경에서는 docker-compose.yml에서 'platform'을 추가하여 빌드에 플랫폼의 운영체제로 지정할 수 있다.

 

version: '3'
services:
  nginx:
    build: ./config/nginx
    ports:
      - "80:80"
    volumes:
      - .:/code
      - ./nginx/nginx:/etc/nginx.conf.d
    image: 11thbackend/nginx:latest
    depends_on:
      - web
    platform: linux/amd64
  web:
    build:
      context: .
      dockerfile: Dockerfile
    command: gunicorn --bind 0.0.0.0:8000 hackathon.wsgi:application
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    platform: linux/amd64
    image: 11thbackend/web:latest

이런식으로 말이다.

그런데, 막상 ec2 서버에서 docker-compose pull을 받았으나, platform이 해당 버전에서 지원하지 않는다고 나왔다.

알고보니 docker-compose를 너무 대충 받았었다.

https://github.com/docker/compose/releases/tag/v2.9.0

 

Release v2.9.0 · docker/compose

⚠️ Warning notice ⚠️ Note Compose v2.9.0 contains changes to environment variable precedence that have since been reverted. We recommend using v2.10+ to avoid compatibility issues. Note This ver...

github.com

여기로 들어가서 맞는 운영체제(나는 linuc x86-64로 받음)의 링크를 복사하고

sudo curl -L 링크주소 -o /usr/local/bin/docker-compose

로 docker-compose를 설치한다.

sudo chmod +x /usr/local/bin/docker-compose

그리고, 권한을 주고 마지막으로

docker-compose --version

으로 잘 설치되었나 본다.

 

-참고자료

 

Compose file version 2 reference

 

docs.docker.com

 

Comments