69
79

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で立ち上げたアプリケーションにアクセスできない

Posted at

久々にdockerを触ると毎回やってしまうウッカリがあるので、自戒のためメモ。

まずは試しにnginxを立ち上げる。

$ docker run -dit -p 8080:80 nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
fdd5d7827f33: Pull complete
a3ed95caeb02: Pull complete
716f7a5f3082: Pull complete
7b10f03a0309: Pull complete
Digest: sha256:f6a001272d5d324c4c9f3f183e1b69e9e0ff12debeb7a092730d638c33e0de3e
Status: Downloaded newer image for nginx:latest
d601ae7d19e3c643b6c0806347b717557fc2da98dcd82968a870247f82fea370

その後、URL http://localhost:8080 にアクセス...
しようとしたものの、ブラウザには このサイトにアクセスできません という表示が。。。

そういえば、dockerのアドレスにアクセスしないといけないんだった。
ということで、以下のコマンドのどれかでIPを確認。

$ docker-machine env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/yukofeb/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell:
# eval $(docker-machine env)

$ docker-machine ip
192.168.99.100

$ echo $DOCKER_HOST
tcp://192.168.99.100:2376

ということで、 http://192.168.99.100:8080 で無事に表示される。
考えてみれば当たり前だけど、毎回やってしまうので気をつけよう。

69
79
1

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
69
79

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?