docker: Network timed out...
Docker for macで初めてDockerに触ってみたが
$ docker run hello-world
すると
Unable to find image 'hello-world:latest' locally Pulling repository docker.io/library/hello-world docker: Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/hello-world/images. You may want to check your internet connection or if you are behind a proxy.. See 'docker run --help'.
てな具合で、先に進めない。
ぐぐると
$ docker-machine restart default $ eval $(docker-machine env default)
Host does not exist: "default"
となる。
そもそもdefaultと言うものがない。
defaultについてさらにぐぐると
$ docker-machine create -d virtualbox default
という記述を見つける
(自分のMacにはvirtualboxはすでにInstall済み。だが、Installしているvirtualboxのことなのだろうか?)
$ docker-machine create -d virtualbox default Creating CA: /Users/abcdefg/.docker/machine/certs/ca.pem Creating client certificate: /Users/abcdefg/.docker/machine/certs/cert.pem Running pre-create checks... (default) Image cache directory does not exist, creating it at /Users/abcdefg/.docker/machine/cache... (default) No default Boot2Docker ISO found locally, downloading the latest release... (default) Latest release for github.com/boot2docker/boot2docker is v1.12.6 (default) Downloading /Users/abcdefg/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v1.12.6/boot2docker.iso... (default) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100% Creating machine... (default) Copying /Users/abcdefg/.docker/machine/cache/boot2docker.iso to /Users/abcdefg/.docker/machine/machines/default/boot2docker.iso... (default) Creating VirtualBox VM... (default) Creating SSH key... (default) Starting the VM... (default) Check network to re-create if needed... (default) Found a new host-only adapter: "vboxnet0" (default) Waiting for an IP... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with boot2docker... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... Checking connection to Docker... Docker is up and running! To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env default
$ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default - virtualbox Running tcp://192.168.99.100:2376 v1.12.6
なんか出来てるし、Virtualboxにもなんか出来てる。
これがDockerコンテナを動かすホストなのかな?
$ docker-machine restart default Restarting "default"... (default) Check network to re-create if needed... (default) Waiting for an IP... Waiting for SSH to be available... Detecting the provisioner... Restarted machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
ぉぉぉーすすんだ!
$ eval $(docker-machine env default)
$ docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 78445dd45222: Pull complete Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 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. 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://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
ぉー!動いたらしい!!
https://docs.docker.com/docker-for-mac/
に戻って
$ docker run -d -p 80:80 --name webserver nginx Unable to find image 'nginx:latest' locally latest: Pulling from library/nginx 75a822cd7888: Pull complete 0aefb9dc4a57: Pull complete 046e44ee6057: Pull complete Digest: sha256:fab482910aae9630c93bd24fc6fcecb9f9f792c24a8974f5e46d8ad625ac2357 Status: Downloaded newer image for nginx:latest ed83898c498d41796a90fe2368e0181d22267562b95e684dc6ff9c88d5de944c
入ったらしいがどうすればいいんだろう?
サンプルではhttp://localhost/にアクセスしろって言ってるけど、だめだった
$ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default - virtualbox Running tcp://192.168.99.100:2376 v1.12.6
このIPかな?ってことで
http://192.168.99.100
にアクセスしたら
やったー!