관리 메뉴

피터의 개발이야기

[Docker] 맥북M1에 도커 컨테이너 colima설치 본문

DevOps/Docker

[Docker] 맥북M1에 도커 컨테이너 colima설치

기록하는 백앤드개발자 2024. 3. 17. 09:54
반응형

ㅁ 들어가며

https://www.docker.com/blog/updating-product-subscriptions/

 Docker Desktop의 이용약관을 보면 대기업에서는 이제 무료로 사용할 수 없게 되었습니다. 그리고 Intel 칩에서만 가동되었던 오라클 컨테이너의 경우 M1에는 돌아가지 않는 문제점도 있습니다. 그래서 Intel과 M1을 둘다 지원해주는 Colima를 설치하는 과정을 정리하였습니다.  

 

 

 

ㅁ Colima의 특징

https://github.com/abiosoft/colima

  • Intel 및 M1 Mac 지원
  • 간단한 CLI 인터페이스
  • Docker 및 Containerd 지원
  • 포트 포워딩
  • 볼륨 마운트
  • 쿠버네티스
  • 다중 인스턴스

최소한의 설정으로 macOS에서 컨테이너 런타임을 제공합니다.

 

 

ㅁ Homebrew로 설치

brew install colima

 

ㅁ Colima 실행

# VM을 4CPU 및 8GiB 메모리로 실행
$ colima start --cpu 4 --memory 8

# 1CPU, 2GiB 메모리 및 10GiB 스토리지를 갖춘 VM을 만듭니다.
$ colima start --cpu 1 --memory 2 --disk 10

# Rosetta 2 에뮬레이션으로 VM 설정
$ colima start --arch aarch64 --vm-type=vz --vz-rosetta

 ㅇ CPU 4 core와 Memory 8GB로 설정하여 실행하였습니다.

 ㅇ macOS에서 다양한 컨테이너 런타임 환경을 만들 수 있습니다.

 

 

ㅁ Docker Desktop을 colima로 변경하기

# Docker client의 Endpoint 목록조회
$ docker context ls
NAME            DESCRIPTION                               DOCKER ENDPOINT                                          ERROR
colima *        colima                                    unix:///Users/peterica.seo/.colima/default/docker.sock
default         Current DOCKER_HOST based configuration   unix:///var/run/docker.sock
desktop-linux   Docker Desktop                            unix:///Users/peterica.seo/.docker/run/docker.sock

# colima로 Endpoint 변경
$ docker context use colima
colima
Current context is now "colima"

 

 

ㅁ Colima Edit(2024.03.17 update)

ㅇ colima 생성 시 옵션 보기
  ㄴ container runtimer을 생성 시 edit 옵션을 적용하면 옵션의 종류 및 설명을 확인할 수 있다.

  ㄴ vi 편집 환경에서 주석을 읽고 옵션을 적용한 후 profile명으로 저장하면 runtimer가 생성된다.

  ㄴ 기존 profile명으로 하면 변경된 옵션이 적용된다. 

$ colima start -p profile-test --edit

# ============================================================================================ #
# To abort, delete the contents of this file including the comments and save as an empty file
# ============================================================================================ #

# Number of CPUs to be allocated to the virtual machine.
# Default: 2
cpu: 2

# Size of the disk in GiB to be allocated to the virtual machine.
# NOTE: changing this has no effect after the virtual machine has been created.
# Default: 60
disk: 60

# Size of the memory in GiB to be allocated to the virtual machine.
# Default: 2
memory: 2

# Architecture of the virtual machine (x86_64, aarch64, host).
# Default: host
arch: aarch64

# Container runtime to be used (docker, containerd).
# Default: docker
runtime: docker

# Set custom hostname for the virtual machine.
# Default: colima
#          colima-profile_name for other profiles
hostname: ""

# Kubernetes configuration for the virtual machine.
kubernetes:
  # Enable kubernetes.
  # Default: false
  enabled: false

  # Kubernetes version to use.
  # This needs to exactly match a k3s version https://github.com/k3s-io/k3s/releases
  # Default: latest stable release
  version: v1.28.3+k3s2

  # Additional args to pass to k3s https://docs.k3s.io/cli/server
  # Default: traefik is disabled
  k3sArgs:
    - --disable=traefik

# Auto-activate on the Host for client access.
# Setting to true does the following on startup
#  - sets as active Docker context (for Docker runtime).
#  - sets as active Kubernetes context (if Kubernetes is enabled).
# Default: true
autoActivate: true

# Network configurations for the virtual machine.
network:
  # Assign reachable IP address to the virtual machine.
  # NOTE: this is currently macOS only and ignored on Linux.
  # Default: false
  address: false

  # Custom DNS resolvers for the virtual machine.
  #
  # EXAMPLE
  # dns: [8.8.8.8, 1.1.1.1]
  #
  # Default: []
  dns: []

  # DNS hostnames to resolve to custom targets using the internal resolver.
  # This setting has no effect if a custom DNS resolver list is supplied above.
  # It does not configure the /etc/hosts files of any machine or container.
  # The value can be an IP address or another host.
  #
  # EXAMPLE
  # dnsHosts:
  #   example.com: 1.2.3.4
  dnsHosts: {}

# ===================================================================== #
# ADVANCED CONFIGURATION
# ===================================================================== #

# Forward the host's SSH agent to the virtual machine.
# Default: false
forwardAgent: false

# Docker daemon configuration that maps directly to daemon.json.
# https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file.
# NOTE: some settings may affect Colima's ability to start docker. e.g. `hosts`.
#
# EXAMPLE - disable buildkit
# docker:
#   features:
#     buildkit: false
#
# EXAMPLE - add insecure registries
# docker:
#   insecure-registries:
#     - myregistry.com:5000
#     - host.docker.internal:5000
#
# Colima default behaviour: buildkit enabled
# Default: {}
docker: {}

# Virtual Machine type (qemu, vz)
# NOTE: this is macOS 13 only. For Linux and macOS <13.0, qemu is always used.
#
# vz is macOS virtualization framework and requires macOS 13
#
# Default: qemu
vmType: qemu

# Utilise rosetta for amd64 emulation (requires m1 mac and vmType `vz`)
# Default: false
rosetta: false

# Volume mount driver for the virtual machine (virtiofs, 9p, sshfs).
#
# virtiofs is limited to macOS and vmType `vz`. It is the fastest of the options.
#
# 9p is the recommended and the most stable option for vmType `qemu`.
#
# sshfs is faster than 9p but the least reliable of the options (when there are lots
# of concurrent reads or writes).
#
# Default: virtiofs (for vz), sshfs (for qemu)
mountType: sshfs

# Propagate inotify file events to the VM.
# NOTE: this is experimental.
mountInotify: true

# The CPU type for the virtual machine (requires vmType `qemu`).
# Options available for host emulation can be checked with: `qemu-system-$(arch) -cpu help`.
# Instructions are also supported by appending to the cpu type e.g. "qemu64,+ssse3".
# Default: host
cpuType: ""

# Custom provision scripts for the virtual machine.
# Provisioning scripts are executed on startup and therefore needs to be idempotent.
#
# EXAMPLE - script executed as root
# provision:
#   - mode: system
#     script: apt-get install htop vim
#
# EXAMPLE - script executed as user
# provision:
#   - mode: user
#     script: |
#       [ -f ~/.provision ] && exit 0;
#       echo provisioning as $USER...
#       touch ~/.provision
#
# Default: []
provision: []

# Modify ~/.ssh/config automatically to include a SSH config for the virtual machine.
# SSH config will still be generated in ~/.colima/ssh_config regardless.
# Default: true
sshConfig: true

# Configure volume mounts for the virtual machine.
# Colima mounts user's home directory by default to provide a familiar
# user experience.
#
# EXAMPLE
# mounts:
#   - location: ~/secrets
#     writable: false
#   - location: ~/projects
#     writable: true
#
# Colima default behaviour: $HOME and /tmp/colima are mounted as writable.
# Default: []
mounts: []

# Environment variables for the virtual machine.
#
# EXAMPLE
# env:
#   KEY: value
#   ANOTHER_KEY: another value
#
# Default: {}
env: {}

 

ㅁ Colima 자동완성

$ echo "autoload -U compinit; compinit" >> ~/.zshrc

 ㅇ 지속적으로 Colima 자동완성 기능을 사용할 수 있도록 zsh에 설정을 하였습니다.

 ㅇ 명령어 이후에 탭키를 사용하면 다양한 사용방법을 안내받을 수 있습니다.

 

 

ㅁ Colima 중지하기

$ colima stop

 

 

ㅁ 함께 보면 좋은 사이트

colima github

 

GitHub - abiosoft/colima: Container runtimes on macOS (and Linux) with minimal setup

Container runtimes on macOS (and Linux) with minimal setup - GitHub - abiosoft/colima: Container runtimes on macOS (and Linux) with minimal setup

github.com

반응형
Comments