上記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 | 先にリポジトリを作成し、ホームディレクトリ/git配下にリポジトリをgit cloneしている前提 cd ~/git/リポジトリ/ |
- インストール
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 --disk 32G --memory 4G $ multipass list Name State IPv4 Image ubuntu-dev01 Running 192.168.64.2 Ubuntu 22.04 LTS |
- ローカルのリポジトリをubuntu-dev01の/var/www/htmlにマウントする
1 | $ multipass mount ~/git/リポジトリ ubuntu-dev01:~/var/www/html/ |
もしエラーが出たら $ multipass restart ubuntu-dev01
を実行して再起動させる。
- ubuntu-dev01にログインとアップデート
1 2 3 | $ multipass shell ubuntu-dev01 $ echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null $ sudo apt-get update -y && sudo apt-get upgrade -y |
- リポジトリがマウントされているか確認する
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 | $ multipass restart ubuntu-dev01 $ multipass stop ubuntu-dev01 $ multipass delete ubuntu-dev01 $ multipass purge ubuntu-dev01 |
- イメージを指定して起動
1 | $ multipass launch 23.04 --name ubuntu-dev02 --cpus 4 --disk 32G --memory 4G |
Was this helpful?
0 / 0
1989年生まれのSRE。ホスティングから大規模なアドテクなどのインフラエンジニアとして携わる。現在はサービスの信頼性向上、DevOps、可用性、レイテンシ、パフォーマンス、モニタリング、オブザーバビリティ、緊急対応、AWS/Azureでのインフラ構築、Docker開発環境の提供、Kubernetes保守、インフラコード化、新技術の検証、リファクタリング、セキュリティ強化などを担当している。個人開発では「夫婦、パートナー向け家事管理サービス/famii」をCakePHPで開発中。個人事業主では数社サーバー保守とベンチャー企業のインフラコンサルティングやMENTAで未経験者にインフラのコーチング/コミュニティの運用を実施している。また、「脆弱性スキャナVuls」のOSS活動もしており、自称エバンジェリスト/技術広報/テクニカルサポート/コントリビュータでもある。