LoginSignup
23
25

More than 5 years have passed since last update.

【Windows】Docker Toolboxのチュートリアルを社内proxy下でやったときにはまったこととその回避方法【手順まとめ】

Last updated at Posted at 2015-10-23

社内でDocker Toolboxのインストールからhello-worldまでを試そうとしたところ、スムーズに行かなかったので、詰まったところについてまとめました。
結論から言うと、無理にdefaultを使わないこと。

チュートリアルのおおまかな流れ

  1. Docker Toolboxのダウンロード・インストール
  2. Quick start terminal起動(自動でdefault vm 作成)
  3. sshログイン
  4. hello-worldの実行

1番はここでは省略して、2番以降でつまったところを中心に書いていきます。

つまったところ・回避策

  1. Starting VM... が終わらない
  2. docker run hello-worldが上手くいかない

1. Starting VM... が終わらない

流れの2番のところで、通常であれば、Quick start terminalを立ち上げると「default」という名前のVMが自動で作成・起動され、クジラのAAが表示されるはずですが、「Starting VM...」で止まってしまいました。

回避方法:Quick start terminalを一旦止める→再起動

止まっているときにVirtualBoxをみてみると、default VMは起動済みとなっていました。
そこでQuick start terminalを一旦止めて再起動したところ、とりあえずさっきまで止まっていたところを越えてクジラが出てきました。

2. docker run hello-worldが上手くいかない

起動が上手く?いったところで、下記のコマンドでVMにログイン→コンテナ起動を試したところ、hello-worldイメージの取得に失敗しました。


docker-machine ssh default
(ユーザ名:dockerでVMにログイン)
docker run hello-world

ちなみにエラーはこんな感じ。
ローカルにイメージがないので、pullしようとして失敗しているようです。


docker@default:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
Pulling repository docker.io/library/hello-world
Error while pulling image: Get https://index.docker.io/v1/repositories/library/hello-world/images: net/http: TLS handshake timeout

回避策:proxy設定込みで新しくホストを作成する

はじめはdefaultにproxy設定をしようとしましたが、OSがCent OSでもubuntuでもなくCore Linux?ということで、検索してもやりかたがよくわからない。
そこで、ホスト作成時にproxy設定するオプションを使って、新しくホストを作成してしまうことにしました。
コマンドは以下の通りです。(設定は各自の環境に合わせてください。testという名前のVMが作成されます。)


docker-machine create -d virtualbox \
    --engine-env HTTP_PROXY=http://your.proxy.co.jp:port \
    --engine-env HTTPS_PROXY=http://your.proxy.co.jp:port \
    --engine-env NO_PROXY=127.0.0.1 \
    test

ここで注意することは、最初のときと違って「Starting VM...」で止まっても中断しないこと。
今回はちゃんと終わるので、少し待機します。
(私は最初ここで中断してうまくいきませんでした。defaultで止まるのは内部でイメージの取得でも試みているのでしょう。)

完了したら、下記コマンドでホストに入って動作確認をしましょう。


docker-machine ssh test
(ユーザ名:dockerでVMにログイン)
docker run hello-world

こんなメッセージが出ていれば成功です。


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 Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/userguide/

いらなくなったdefaultですが、消すと次回起動時に再生成されてまた処理が止まるという…。
仕方ないので放置です。

今回は以上です。

23
25
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
23
25