1
1

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 1 year has passed since last update.

[WSL vs Mac] WSL 上でのみ、docker compose build の所要時間が膨大になる場合の対策

1
Last updated at Posted at 2024-03-20

概要

WSL だと、 Mac の 10 ~ 100 倍の時間がかかっていることが発覚した。

環境

当然ですが、同じ通信回線を利用して計測しています。
マシンごとの差分は以下の通り。

- Windows Mac
OS Version Windows11 Ventura13.6
チップ AMD Ryzen 7 4700U with Radeon Graphics 2.00GHz Apple M2
コア数 8 8
memory 24GB 24GB

所要時間比較

全く同じ Dockerfile 、 docker-compose.yml ファイルを使って build を行った。

1. WSL で実行時

$ docker compose build

...

 => [2/6] RUN export DEBIAN_FRONTEND=noninteractive     && apt -y update && apt   291.3s
 => [3/6] RUN apt-get install -y --no-install-recommends     curl     gcc     g  3720.6s
 => [4/6] WORKDIR /workspace                                                        0.0s 
 => [5/6] COPY ./requirements.txt requirements.txt                                  0.0s
...
  • apt update に 291 秒
  • apt-get install に 3720 秒

かかっている。

ちなみに、WSL での build は、最終的に pip install 実行中にタイムアウトした。

2. Mac で実行時

% docker compose build
[+] Building 60.4s (10/10) FINISHED

...

 => [2/6] RUN export DEBIAN_FRONTEND=noninteractive     && apt -y update && apt -y upgrade                                     11.3s
 => [3/6] RUN apt-get install -y --no-install-recommends     curl     gcc     g++     git     net-tools     vim     libopencv  37.3s 
 => [4/6] WORKDIR /workspace                                                                                                    0.0s 
 => [5/6] COPY ./requirements.txt requirements.txt
...

Mac の場合、

  • apt update に 11 秒
  • apt-get install に 37 秒

で済んだ。当然、全く同じパッケージをインストールさせている。その前提の下で、これだけの時間差が生じている。

端的に言って、WSL は通信が遅すぎてマズイ。

対策

どうやら対策は存在するらしいが、windows の設定を変更して元に戻せないリスクを考えると実行に踏み切れない。

手を出してみた。(2024/08/24)

Linuxと違って全く経験がないので、どうしても必要になるまでは手を出したくない。

この記事の方法で、docker イメージの build 速度が圧倒的に改善したので、是非試してほしい。

この記事単独だと、一見して実行コマンドが分かりにくいので、記事の末尾にあるコメント欄に、実行したコマンドを記載させていただいています(o_ _)o))

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?