2
0

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 3 years have passed since last update.

【エラー】 Docker build時のエラー(最新版のimageをpullして解決)

Last updated at Posted at 2021-01-06

概要

  • Dockerの勉強中にbuidでこけたのでその対処をしたので、その備忘。
  • 解決方法としては単にベースのイメージが古かったので新しくpullしてbuildして終了。

状況と対処

buildしたDockerfile

Dockerfileは非常にシンプルで、ubuntu:latestをベースにパッケージをインストールしている。

Dockerfile
FROM ubuntu:latest
RUN apt-get update && apt-get install -y \ 
	curl \
	nginx

エラー

セキュリティーが怪しそうとのことなのでおそらくdocker imageが古い?

$ docker build .
Sending build context to Docker daemon  6.656kB
Step 1/2 : FROM ubuntu:latest
 ---> 9140108b62dc
Step 2/2 : RUN apt-get update && apt-get install -y 	curl 	nginx
 ---> Running in b37d029342e6
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [109 kB]
Ign:4 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
Ign:5 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
Get:6 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [741 B]
Get:4 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [516 kB]
Err:4 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
  File has unexpected size (515215 != 515734). Mirror sync in progress? [IP: 91.189.91.39 80]
  Hashes of expected file:
   - Filesize:515734 [weak]
   - SHA256:6edc1a6f67f0e67da44c8aa3455144dba75d1f11ecd18bb9881634574c4a5b10
   - SHA1:8639b548198806c25d72f9dd9e9a9d6f86dcb895 [weak]
   - MD5Sum:b29deacaed369971375c55ea72765d06 [weak]
  Release file created at: Wed, 06 Jan 2021 13:47:03 +0000
Get:7 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:5 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [646 kB]
Err:5 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages

Get:8 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:11 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [30.0 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [897 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [145 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [916 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [4250 B]
Fetched 15.5 MB in 12min 47s (20.2 kB/s)
Reading package lists...
E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/main/binary-amd64/Packages.gz  File has unexpected size (515215 != 515734). Mirror sync in progress? [IP: 91.189.91.39 80]
   Hashes of expected file:
    - Filesize:515734 [weak]
    - SHA256:6edc1a6f67f0e67da44c8aa3455144dba75d1f11ecd18bb9881634574c4a5b10
    - SHA1:8639b548198806c25d72f9dd9e9a9d6f86dcb895 [weak]
    - MD5Sum:b29deacaed369971375c55ea72765d06 [weak]
   Release file created at: Wed, 06 Jan 2021 13:47:03 +0000
E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/universe/binary-amd64/Packages.gz
E: Some index files failed to download. They have been ignored, or old ones used instead.
The command '/bin/sh -c apt-get update && apt-get install -y 	curl 	nginx' returned a non-zero code: 100

解決

docker imageを確認すると3か月前だったのでとりあえず最新版のimageをpullしてそれを元にbuildしたらいけた。

$ docker images
REPOSITORY                     TAG       IMAGE ID       CREATED         SIZE
ubuntu                         latest    9140108b62dc   3 months ago    72.9MB

$ docker pull ubuntu:latest
latest: Pulling from library/ubuntu
da7391352a9b: Pull complete
14428a6d4bcd: Pull complete
2c2d948710f2: Pull complete
Digest: sha256:c95a8e48bf88e9849f3e0f723d9f49fa12c5a00cfc6e60d2bc99d87555295e4c
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest

もう一度docker buildしてみたら成功した。

$ docker build .
Sending build context to Docker daemon  6.656kB
Step 1/3 : FROM ubuntu:latest
 ---> f643c72bc252
Step 2/3 : RUN apt-get update
 ---> Running in 526d97fff024
Get:1 http://archive.ubuntu.c

略

Successfully built a4360c2d987b
2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?