現象
Macでdevcontainerを使って開発していた。Macでは問題なかった。
windowsで開く用事があって、そのリポジトリをwindows側でクローンし、コンテナでリビルドして開くをしたところエラーでビルドできなかった。
[2025-05-13T05:03:50.638Z] Error fetching image details: read ECONNRESET
[2025-05-13T05:03:50.638Z] Start: Run: docker pull mcr.microsoft.com/devcontainers/python
[2025-05-13T05:03:50.848Z]
[2025-05-13T05:03:50.864Z] Using default tag: latest
[2025-05-13T05:03:52.142Z] Error response from daemon: Head "https://mcr.microsoft.com/v2/devcontainers/pyt
hon/manifests/latest": EOF
[2025-05-13T05:03:52.206Z] Stop (1568 ms): Run: docker pull mcr.microsoft.com/devcontainers/python
[2025-05-13T05:03:52.207Z] []
[2025-05-13T05:03:52.207Z] Error response from daemon: No such image: mcr.microsoft.com/devcontainers/python:latest
原因調査
ChatGPTに相談したところ、まずネットワークの確認を指示された。
- mcr.microsoft.com への疎通確認
curl -v https://mcr.microsoft.com/v2/
→ 200 OK が返れば正常、タイムアウトならネットワーク・FW・Proxyを確認
実行してみた↓
$ curl -v https://mcr.microsoft.com/v2/
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Host mcr.microsoft.com:443 was resolved.
* IPv6: 2603:1061:f:101::10, 2603:1061:f:100::10
* IPv4: 150.171.69.10, 150.171.70.10
* Trying [2603:1061:f:101::10]:443...
* Connected to mcr.microsoft.com (2603:1061:f:101::10) port 443
* schannel: disabled automatic use of client certificate
* Recv failure: Connection was reset
* schannel: failed to receive handshake, SSL/TLS connection failed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
* closing connection #0
curl: (35) Recv failure: Connection was reset
「TCP接続はできているが、SSL/TLSハンドシェイクで接続リセット (Connection reset)」が起きています。とのこと
対策
IPv6を無効化して再試行
一時的にIPv6を無効にしてIPv4で再接続を試す:
Windows (PowerShell 管理者権限)
Disable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6
をして、もう一度ビルドすると問題なくコンテナを開くことができました。
トラブル時はIPv6を一時的にOFFにし、終わったら元に戻す運用がベストとのこと
Windows (PowerShell 管理者権限)
# 有効化
Enable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6