dockerをMacに入れる方法について書いてみたいと思います。
方法は色々あるかと思いますが、私はもっぱらhomebrewしか使っていません。 これはdockerに限らず、何かソフトウェアを入れたいときはhomebrewにパッケージがあるかどうかをまずは確認し、なければ渋々dmgを探してインストールしています。
まず、homebrewが入っているかの確認をするには、ターミナルから以下を実行してください。
brew --version
入っていれば、以下のような結果が返ってくるはずです。
Homebrew 4.0.15 Homebrew/homebrew-core (git revision 830070c393f; last commit 2023-02-18) Homebrew/homebrew-cask (git revision 1a8cad145c; last commit 2023-02-18)
もし入っていなかったら以下を実行してください。
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
なお、こちらが公式サイトです。気になる方はこちらも参考にしてください。
ちなみに、パッケージの検索はこちらからできます。
Dockerのインストール
以下のコマンドをターミナルから実行してください。
brew install --cask docker
Dockerのエンジン管理にGUIを使うので、--caskオプションをつけています。
Dockerアカウントの作成
こちらからアカウントの作成をしてください。支払い情報などの入力は不要です。
Dockerエンジンの起動
dockerではエンジンとなるプロセスがまずは起動します。これを起動しておかないとdockerコマンドを実行しても成功しません。
spotlightなどからdockerを起動すると良いでしょう。
正常に起動していれば、以下のようなアイコンがメニューバーに出ているはずです。
最後に動作確認をしてみます。docker
コマンドの詳細な使い方は置いておくとして、以下のコマンドで動作確認ができます。
docker run hello-world
以下の結果が出力されていれば、正常に動作しています。 また、最初の5行は手元にコンテナイメージがない場合、つまり初回などに出力されるメッセージです。
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 7050e35b49f5: Pull complete Digest: sha256:4e83453afed1b4fa1a3500525091dbfca6ce1e66903fd4c01ff015dbcb1ba33e Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (arm64v8) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
ひとまず、ここまで完了すれば、dockerのインストールは完了です。