つまずいたポイントをメモ
あらゆるdockerコマンドが Cannot connect to the Docker daemon
となり実行できない
$ docker ps
Cannot connect to the Docker daemon at tcp://12.168.99.100:2376. Is the docker daemon running?
これはenvの設定が間違っていてVMに接続できていないのが原因だった
DOCKER_HOST=tcp://12.168.99.100:2376 # IPが間違っていたり
DOCKER_MACHINE_NAME=default # VM名が違っていたり
DOCKER_TLS_VERIFY=1
DOCKER_CERT_PATH=/Users/username/.boot2docker/certs/boot2docker-vm # パスが過去に入れていたboot2dockerのものになっていたり
docker-machine env default
で正しい設定が得られるので、
$ eval "$(docker-machine env default)"
$ source ~/.bash_profile
を実行して書き直してあげればOK
ブラウザからアクセスできない
これはVMの方のポートフォワーディングの設定が間違っていたのが原因だった
Railsアプリをポート3000で起動してhttp://localhost:3000でアクセスしようとして以下のコマンドでコンテナ作成
$ docker run -d -p 3000:3000 developer_name/project_name
だが繋がらない:(
調べた所Virtualboxの方でポートフォワーディングの設定が間違っていたので、以下のような設定に変更
defaultを選択 > 歯車のアイコンで設定を開く > ネットワーク > アダプター1 > 「高度」を選択 > ポートフォワーディング から
3000:3000なら上記のような設定を追加