0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Docker] MacでDockerを動かすときにつまずいたポイント

Last updated at Posted at 2017-02-11

つまずいたポイントをメモ

あらゆる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 > 「高度」を選択 > ポートフォワーディング から

image

3000:3000なら上記のような設定を追加

これでhttp://localhost:3000でつながるようになった。

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?