7
5

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 Desktop for WindowsにProxyを設定した

Posted at

解決すべき問題

Docker Desktop for Windows (v2.2.0.3) をWindows 10 PCにインストールした。docker pull nginxコマンドが失敗した。Proxyがある環境だったから。%USERPROFILE%\.docker\config.json ファイルにProxyの設定を記入した。config.jsonを反映するためにDocker Desktopを再起動した。docker pull nginxを再度実行したら、やはり失敗した。

説明

Proxyサーバによってインターネットから隔てられた会社のネットワーク上のPCでDocer for Windowsをインストールした。PowerShellのウインドウを開いてDockerAtHomeプロジェクトの 5-1 のサンプルを試みた。するとdockerコマンドがDocker Hubに通信しようとしてエラーが発生した。

> docker pull nginx
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: EOF

Proxyの問題だろうとおもった。 https://qiita.com/2fbCvmiYKX/items/c6aab333364af25fd924 を参照した。対策として%USERPROFILE%\.docker\config.json ファイルにProxyの設定を追加した。

{
    "credsStore":"desktop",
    "proxies": {
        "default": {
            "httpProxy": "http://172.24.xx.xx:8080",
            "httpsProxy": "http://172.24.xx.xx:8080",
            "noProxy": ""
        }
    },
    "stackOrchestrator":"swarm"
}

docker pull nginxコマンドを再試行した。エラーが解消しなかった。

別解

もう一つのQiita記事 https://qiita.com/wryun0suke/items/1f4bbd2977ae41ee7a36 をみた。こちらの記事は「タスクトレイにあるDockerアイコンを右クリックして「Settings…」を開いた...」と書いてある。ほほう、別のやり方があるのね。でも「タスクトレイにあるDockerアイコン」って何?しばし迷ったが、最終的に問題を解決することができた。

タスクトレイとはディスクプレイに右下隅のあたりにある。上向き矢印 ^ をクリックすると隠れていたアイコンが表示される。そのなかにDockerアイコンがいた。
1_tasktray.png

Dockerアイコンを右クリックして Settings メニューを選んだ。
2_menu_settings.png

Settingsダイアログが表示された。メニューで Settings > Resources> PROXIES を選んだ。

Manual proxy configurationをONし、HTTPのProxyとHTTPSのProxyを設定した。
3_settings_resources_proxies.png

Apply & Restartボタンを押すとDocker Desktopが停止・再起動した。数分かかった。

このあとで docker pull nginx を再試行したところ、成功した。メデタシ、メデタシ。

結論

Docker Desktop for Windows v2.2.0.3 は %USERPROFILE%\.docker\config.json に書かれたProxiesの設定を読まない。GUIでSettingsダイアログを開き入力する必要がある。

本家のドキュメントGet started with Docker for Windowsをみると、GUIでSettingsダイアログを開いて入力しろとたしかに書いてある。ところが「.docker/config.jsonは使わない」とは書いていない。config.jsonはLinux上でdockerコマンドを動かす場合に必要になるものであって、Docker Desktop for Windowsにはまるで関係なかった。うーむ、自分がdocker初心者であることをおもい知った。

7
5
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
7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?