[Error] Error during Docker build (solved by pulling the latest version of image)

Overview

Situation and coping

built Dockerfile

The Dockerfile is very simple and installs packages based on ubuntu: latest.

Dockerfile


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

error

Perhaps the docker image is old because security seems to be suspicious?

$ 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

Solution

When I checked the docker image, it was 3 months ago, so I had to pull the latest version of the image and build it based on it.

$ 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

I tried docker build again and it succeeded.

$ 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

Abbreviation

Successfully built a4360c2d987b

Recommended Posts

[Error] Error during Docker build (solved by pulling the latest version of image)
Install by specifying the version of Django in the Docker environment
About the version of Docker's Node.js image
Install the latest version of Jenkins on Ubuntu 16
Change the location folder of Docker image & container
Weight reduction of Docker image by multi-stage build-React application
[CentOS] Download and build the specified version of Git
Image processing: The basic structure of the image read by the program
I tried to build the environment little by little using docker
I tried to build the environment of WSL2 + Docker + VSCode
(Fixed) An error occurs when using Java 8 with the latest version (0.65.0) of Language Support for Java (TM) by Red Hat of VS Code.
When the docker image created on Raspberry pi is read by docker on windows, the error "exec format error" appears.
Docker monitoring-explaining the basics of basics-
Understand the basics of docker
Switch the version of bundler
Switch the version of java installed by SDKMAN when moving directories
I tried to build the environment of PlantUML Server with Docker
The repository ... is not signed error in docker build apt-get update
How to build Rails + Vue + MySQL environment with Docker [2020/09 latest version]