LoginSignup
24
21

More than 5 years have passed since last update.

docker-machineをVirtualBoxで使用するときにホストオンリーアダプターのIPアドレスを設定する

Posted at

前提

devという名前の仮想環境を以下のように作ったとする。

$ docker-machine create --driver virtualbox dev

devのIPアドレスを確認する

$ docker-machine ip dev
xxx.xxx.xxx.xxx #ダミーです

↑ このIPアドレスが固定となり、VirtualBoxの設定でホストオンリーアダプターのIPアドレスをいくら変更しても変わってくれない。または、docker-machine start devすると新しいホストオンリーアダプターが設定されてしまう。

docker-machineのconfigを修正する

Macの場合、以下のディレクトリにconfigファイルがあります。
/User/(ユーザ名)/.docker/machine/machines/dev/config.json

このconfig.jsonファイルになっていて、以下の箇所を上書き修正します。

"HostOnlyCIDR":"xxx.xxx.xxx.xxx"

以上

どこにも書かれていないので、メモ。

24
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
21