上記M1 Mac/Apple silicon(ARM)だとVagrantが使えないため、Linuxでサーバー構築の学習が困難であったが、代替としてMultipassを利用すれば可能である。また、デフォルトのOSは Ubuntu 22.04.2 LTS となる。ローカルからAnsibleも実行可能で、概念はVagrantとほぼ同じで学習コストは低いが、Ubuntuしか使えないのがデメリット。もちろんUbuntu上にVagrantをインストールできるが、必要ないので削除すること。
https://multipass.run/docs/mac-tutorial
- 準備
| 1 2 3 4 | - 先にリポジトリを作成し、ホームディレクトリ/git配下にリポジトリをgit cloneしている前提 $ mkdir ~/git $ cd ~/git/ $ git clone sshでのリポジトリリンク | 
- インストール
| 1 2 | $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" $ brew install --cask multipass | 
- アプリケーションのMultipassをクリックして起動する
- 起動
| 1 2 3 4 5 | $ multipass launch --name ubuntu-dev01 --cpus 4 --memory 8G --disk 32G  $ multipass list Name                    State             IPv4             Image ubuntu-dev01                 Running           192.168.64.2     Ubuntu 22.04 LTS | 
- ubuntu-dev01にログインとアップデート
| 1 2 | $ multipass shell ubuntu-dev01 $ sudo apt-get update -y && sudo apt-get upgrade -y | 
開発環境でローカルのコードをvmにマウントしたい場合
- ローカルのリポジトリをubuntu-dev01の/var/www/htmlにマウントする
| 1 2 3 4 | $ multipass shell ubuntu-dev01 $ sudo mkdir -p /var/www/html $ exit $ multipass mount ~/git/リポジトリ ubuntu-dev01:/var/www/html/ | 
もしエラーが出たら $ multipass restart ubuntu-dev01 を実行して再起動させる。
- リポジトリがマウントされているか確認する
| 1 | $ ls -al /var/www/html/ #ローカルのリポジトリがマウントしていればOK | 
補足
- その他のオプション
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | $ multipass -h Usage: multipass [options] <command> Create, control and connect to Ubuntu instances. This is a command line utility for multipass, a service that manages Ubuntu instances. Options:   -h, --help     Displays help on commandline options   -v, --verbose  Increase logging verbosity. Repeat the 'v' in the short option                  for more detail. Maximum verbosity is obtained with 4 (or more)                  v's, i.e. -vvvv. Available commands:   alias         Create an alias   aliases       List available aliases   authenticate  Authenticate client   delete        Delete instances   exec          Run a command on an instance   find          Display available images to create instances from   get           Get a configuration setting   help          Display help about a command   info          Display information about instances   launch        Create and start an Ubuntu instance   list          List all available instances   mount         Mount a local directory in the instance   networks      List available network interfaces   purge         Purge all deleted instances permanently   recover       Recover deleted instances   restart       Restart instances   set           Set a configuration setting   shell         Open a shell on a running instance   start         Start instances   stop          Stop running instances   suspend       Suspend running instances   transfer      Transfer files between the host and instances   umount        Unmount a directory from an instance   unalias       Remove aliases   version       Show version details | 
- イメージ一覧
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | $ multipass find Image                       Aliases           Version          Description 20.04                       focal             20230731         Ubuntu 20.04 LTS 22.04                       jammy,lts         20230729         Ubuntu 22.04 LTS 23.04                       lunar             20230729         Ubuntu 23.04 Blueprint                   Aliases           Version          Description anbox-cloud-appliance                         latest           Anbox Cloud Appliance charm-dev                                     latest           A development and testing environment for charmers docker                                        0.4              A Docker environment with Portainer and related tools jellyfin                                      latest           Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media. minikube                                      latest           minikube is local Kubernetes ros-noetic                                    0.1              A development and testing environment for ROS Noetic. ros2-humble                                   0.1              A development and testing environment for ROS 2 Humble. | 
- Multipassの再起動、停止、削除
※停止しないとPCが重くなるので、作業しないときは停止しておくこと。
| 1 2 3 4 5 6 7 | $ multipass restart ubuntu-dev01 #再起動 $ multipass stop ubuntu-dev01 #使わないときは停止 $ multipass start ubuntu-dev01 #利用するときに起動 $ pkill multipass #それでも重い場合はプロセスをkillしてみる $ multipass delete ubuntu-dev01 #削除 $ multipass purge #完全に削除 | 
- イメージを指定して起動
| 1 | $ multipass launch 23.04 --name ubuntu-dev02 --cpus 4 --memory 8G --disk 32G | 
Was this helpful?
0 / 0
1989年生まれのFindy/SRE サブマネージャー。ホスティングから大規模なアドテクなどのインフラエンジニアとして携わる。現在はサービスの信頼性向上、DevOps、可用性、レイテンシ、パフォーマンス、モニタリング、オブザーバビリティ、緊急対応、AWSでのインフラ構築、Docker開発環境の提供、IaC、新技術の検証、リファクタリング、セキュリティ強化、分析基盤の運用、チームマネジメントを担当している。
個人事業主では数社サーバー保守とベンチャー企業のインフラコンサルティングを行うほか、TechBullを創業し、未経験者向けにSREのコーチングやコミュニティ運営、LT大会の開催、 会員管理システム「Members」の開発をリードしている。さらに、エンジニア向けYouTubeメディア「TECH WORLD」ではSRE関連の動画に出演し、過去には脆弱性スキャナ「Vuls」のOSS活動にも貢献。