LoginSignup
10
2

More than 3 years have passed since last update.

【Docker】えっちなサイトを見ないように、webコンテンツの制限をしたらdocker-buildに失敗した話。Err:4 http://deb.debian.org/debian buster/main amd64 Packages File has unexpected size (13341 != 7906864). Mirror sync in progress?

Last updated at Posted at 2021-04-01
docker-compose run -d web --build

を実行したら

WARNING: The Docker Engine you're using is running in swarm mode.

Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.

To deploy your application across the swarm, use `docker stack deploy`.

Building web
Step 1/18 : FROM ruby:2.6.5
 ---> ad10dfbc638b
Step 2/18 : RUN apt-get update && apt-get install -y curl apt-transport-https wget && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && apt-get update && apt-get install -y yarn
 ---> Running in 80bf7fe2a0a3
Get:1 http://deb.debian.org/debian buster InRelease [121 kB]
Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Err:4 http://deb.debian.org/debian buster/main amd64 Packages
  File has unexpected size (13341 != 7906864). Mirror sync in progress? [IP: 151.101.110.132 80]
  Hashes of expected file:
   - Filesize:7906864 [weak]
   - SHA256:935deda18d5bdc25fb1813d0ec99b6e0e32a084b203e518af0cf7dc79ee8ebda
   - MD5Sum:ba791e511a2a4b6523ac06f404e32f42 [weak]
  Release file created at: Sat, 27 Mar 2021 09:55:13 +0000
Get:5 http://security.debian.org/debian-security buster/updates/main amd64 Packages [269 kB]
Err:5 http://security.debian.org/debian-security buster/updates/main amd64 Packages
  File has unexpected size (13391 != 269164). Mirror sync in progress? [IP: 151.101.110.132 80]
  Hashes of expected file:
   - Filesize:269164 [weak]
   - SHA256:17e49b3ad8a5db3a133f479410013c4f5520be17c6b450178d91fb833b58ab41
   - MD5Sum:8c5dc1de7f80948051eca9f1b9dd60a0 [weak]
  Release file created at: Tue, 30 Mar 2021 21:21:24 +0000
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [9504 B]
Err:6 http://deb.debian.org/debian buster-updates/main amd64 Packages
  File has unexpected size (13357 != 9504). Mirror sync in progress? [IP: 151.101.110.132 80]
  Hashes of expected file:
   - Filesize:9504 [weak]
   - SHA256:7fdf26b933a6b8680ad878d9d70213edd2c415135536f84b58ff38b9112f2415
  Release file created at: Wed, 31 Mar 2021 02:08:55 +0000
Fetched 239 kB in 1s (459 kB/s)
Reading package lists...
E: Failed to fetch http://deb.debian.org/debian/dists/buster/main/binary-amd64/by-hash/SHA256/935deda18d5bdc25fb1813d0ec99b6e0e32a084b203e518af0cf7dc79ee8ebda  File has unexpected size (13341 != 7906864). Mirror sync in progress? [IP: 151.101.110.132 80]
   Hashes of expected file:
    - Filesize:7906864 [weak]
    - SHA256:935deda18d5bdc25fb1813d0ec99b6e0e32a084b203e518af0cf7dc79ee8ebda
    - MD5Sum:ba791e511a2a4b6523ac06f404e32f42 [weak]
   Release file created at: Sat, 27 Mar 2021 09:55:13 +0000
E: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/main/binary-amd64/by-hash/SHA256/17e49b3ad8a5db3a133f479410013c4f5520be17c6b450178d91fb833b58ab41  File has unexpected size (13391 != 269164). Mirror sync in progress? [IP: 151.101.110.132 80]
   Hashes of expected file:
    - Filesize:269164 [weak]
    - SHA256:17e49b3ad8a5db3a133f479410013c4f5520be17c6b450178d91fb833b58ab41
    - MD5Sum:8c5dc1de7f80948051eca9f1b9dd60a0 [weak]
   Release file created at: Tue, 30 Mar 2021 21:21:24 +0000
E: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/main/binary-amd64/by-hash/SHA256/7fdf26b933a6b8680ad878d9d70213edd2c415135536f84b58ff38b9112f2415  File has unexpected size (13357 != 9504). Mirror sync in progress? [IP: 151.101.110.132 80]
   Hashes of expected file:
    - Filesize:9504 [weak]
    - SHA256:7fdf26b933a6b8680ad878d9d70213edd2c415135536f84b58ff38b9112f2415
   Release file created at: Wed, 31 Mar 2021 02:08:55 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.
ERROR: Service 'web' failed to build : The command '/bin/sh -c apt-get update && apt-get install -y curl apt-transport-https wget && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && apt-get update && apt-get install -y yarn' returned a non-zero code: 100

みたいな、エラーが発生。。。

開発環境が立ち上がらない。それはすなわち死を意味する。

何が原因かも分からないし、エラーをググっても分からないので、
もう初心者の自分にはどうしようもないので、
「丸投げの質問でごめんなさい!」と、ruby-jpの皆様に泣きついた。
丸投げの質問にも関わらず、丁寧に回答してくださり、ありがとうございます。

解決方法

1.エラーメッセージからaptでのファイルのダウンロードがおかしそう

2.File has unexpected size (13341 != 7906864)を見ると、ファイルサイズの比較をしていて、明らかに異なっていそう

3.似たエラーメッセージが3つ出ていて、そのどれもがだいたい同じファイルサイズ(133xx)ぐらいでおかしくなってそう

4.過去の経験から、こういう時は本来のファイルではなくエラー画面をダウンロードしてしまっている可能性が考えられそう。(エラー画面なら似たようなファイルサイズになる説明がつく)

5.ダウンロードに失敗しているURLをDockerの中で眺めてみた( curl ... | head )ら、本来ダウンロードしたかったものではなくエラー画面っぽいHTMLが返ってきていそう

6.じゃあブラウザで見たらどうなるだろう、と見てもらったら、おそらく同じっぽいエラー画面が表示されてそう。(これはエラー画面のHTMLを見比べて同じか確認すると良かったかも)

7.Docker内のエラーもスクリーンタイムが影響していそう

@pocke さん、本当にありがとうございました。

と、とてもご丁寧な回答をいただけました。
その他の御回答していただいた、皆様本当にありがとうございます。。。開発環境立ち上がらなくて本当に焦りました。

Dockerfileの中身

FROM ruby:2.6.5

## nodejsとyarnはwebpackをインストールする際に必要
# yarnパッケージ管理ツールをインストール

RUN curl http://deb.debian.org/debian/dists/buster/main/binary-amd64/by-hash/SHA256/935deda18d5bdc25fb1813d0ec99b6e0e32a084b203e518af0cf7dc79ee8ebda | head

RUN apt-get update && apt-get install -y curl apt-transport-https wget && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y yarn


RUN /bin/sh -c /bin/sh -c bundle update --bundler
RUN gem install bundler:2.1.4

RUN mkdir /coffee_passport
WORKDIR /coffee_passport
COPY Gemfile /coffee_passport/Gemfile
COPY Gemfile.lock /coffee_passport/Gemfile.lock
RUN bundle update rails
RUN bundle update
RUN bundle install
COPY . /coffee_passport

RUN yarn install --check-files
RUN bundle exec rails webpacker:compile

# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]

この、

RUN apt-get update && apt-get install -y curl apt-transport-https wget && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y yarn

の部分で、apt-getしに行った、ファイルがwebのよくないコンテンツに引っかかったみたい。

スクリーンショット 2021-04-01 15.30.19.png

ここで、成人向けWebサイトを制限していたのが原因でした。
Docker-composeを実行するためには、
これからはMacの設定ではなく、自分の意思でえっちなサイトを我慢しなくてはならない問題が発生しましたが、プログラミングのためなのでしょうがないです。。。。。

10
2
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
10
2