プログラミングガール

Developing a better me

Docker|certificate has expired or is not yet valid

エラー

Dockerでimageをpullしてくる際に certificate has expired or is not yet valid というエラーに見舞われる。

$ sudo docker container run --name redis -it -p 6379:6379 --net test_network redis
Unable to find image 'redis:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: x509: certificate has expired or is not yet valid.
See ‘docker run --help'.

環境

CentOS 7 on Vagrant

原因

どうやらシステムクロックが現実とズレているために起こるらしい。

# 今日は2018 7/8なので確かにズレとる
$ date
Thu Jun 28 21:54:45 UTC 2018

解決方法

システムクロックを現在時刻に合わせる

$ sudo yum install ntpdate
... Complete!

$ sudo ntpdate ntp.nict.jp
Thu Jun 28 21:54:45 UTC 2018

# うごいたね!
$ docker container run —name redis -it -p 6379:6379 --net test_network redis
Unable to find image 'redis:latest' locally
latest: Pulling from library/redis
...

                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 4.0.10 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'