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

「docker-compose build」時に「Dockerfile」に定義した「apt-get update」ができなかった件

Last updated at Posted at 2020-10-24

#1.本記事の趣旨
dockerにて、golangの開発環境を構築するため、dockerfileを以下のとおり設定していた。
しかし、2.エラー内容のとおり、buildできず。。。
備忘録として残します!

dockerfile
#参考
FROM golang:latest

ENV GO111MODULE=on
ENV GOLANG_VERSION=1.15.3

WORKDIR /go/src/backend

#このapt-getがうまくいかない・・・・
RUN apt-get update -y && apt-get install -y vim

COPY /backend/go.mod /backend/go.sum /go/src/backend/

#2.エラー内容
docker-compose buildがうまくいかず。

[root@localhost vagrant]# docker-compose build
nginx uses an image, skipping
Building vue
Step 1/2 : FROM node:10
 ---> 56387899b840
Step 2/2 : RUN apt-get update &&     apt-get install git &&     npm install -g npm &&     npm install -g @vue/cli
 ---> Using cache
 ---> 2f3aa344d453

Successfully built 2f3aa344d453
Successfully tagged vagrant_vue:latest
Building go
Step 1/7 : FROM golang:latest
 ---> 4a581cd6feb1
Step 2/7 : ENV GO111MODULE=on
 ---> Using cache
 ---> dfe811dc936e
Step 3/7 : ENV GOLANG_VERSION=1.15.3
 ---> Using cache
 ---> dc7206ac34f4
Step 4/7 : ENV GOPATH=/go
 ---> Using cache
 ---> 73183c5707e4
Step 5/7 : WORKDIR /go/src/backend
 ---> Using cache
 ---> a3cb200b2052
Step 6/7 : RUN apt-get update -y && apt-get install -y vim
 ---> Running in a57f9a0f8c5f
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [121 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 [7906 kB]
Reading package lists...
E: Release file for http://security.debian.org/debian-security/dists/buster/updates/InRelease is not valid yet (invalid for another 1d 8h 21min 59s). Updates for this repository will not be applied.
E: Release file for http://deb.debian.org/debian/dists/buster-updates/InRelease is not valid yet (invalid for another 2d 0h 11min 1s). Updates for this repository will not be applied.
ERROR: Service 'go' failed to build : The command '/bin/sh -c apt-get update -y && apt-get install -y vim' returned a non-zero code: 100

ここらへんをみると、時間の設定が悪そう。。。

E: Release file for http://security.debian.org/debian-security/dists/buster/updates/InRelease is not valid yet (invalid for another 1d 8h 21min 59s). Updates for this repository will not be applied.
E: Release file for http://deb.debian.org/debian/dists/buster-updates/InRelease is not valid yet (invalid for another 2d 0h 11min 1s). Updates for this repository will not be applied.

#3.解決法
ホストOS(今回だと、CentOS7)の時間がおかしいのか??

$date
Thu Oct 22 17:49:15 JST 2020

作業日時は、10月24日22:00ごろだったので、間違いなくズレている。。。
ホストOSを現在時刻に以下のサイトを参考に変更してみる。
参考記事名:Linuxサーバー時刻を(現在時刻と)合わせる
参考URL:https://qiita.com/ntkgcj/items/0ef1c02665b3d9a3971d

$ docker-compose build
Building go
Step 1/7 : FROM golang:latest
 ---> 4a581cd6feb1
Step 2/7 : ENV GO111MODULE=on
 ---> Using cache
 ---> dfe811dc936e
Step 3/7 : ENV GOLANG_VERSION=1.15.3
 ---> Using cache
 ---> dc7206ac34f4
Step 4/7 : ENV GOPATH=/go
 ---> Using cache
 ---> 73183c5707e4
Step 5/7 : WORKDIR /go/src/backend
 ---> Using cache
 ---> a3cb200b2052
Step 6/7 : RUN apt-get update -y && apt-get install -y vim
 ---> Running in e5e484eea0df
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [121 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [243 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7906 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7868 B]
・・・省略
Successfully tagged vagrant_go:latest

ビルド成功しました!!

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?