docker拉取镜像失败


问题描述

$ docker-compose up --build
Pulling composer (composer:latest)...
ERROR: Get https://registry-1.docker.io/v2/library/composer/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fcomposer%3Apull&service=registry.docker.io: net/http: TLS handshake timeout


$ docker-compose up --build
Pulling web (nginx:alpine)...
ERROR: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout

使用docker-machine rm, 提示错误.

$ docker-machine rm default                                                                                                              1 ↵
zsh: command not found: docker-machin

使用docker logout也无效

$ docker logout                                                                                                                        127 ↵
Not logged in to https://index.docker.io/v1/
$ docker-compose up --build
Pulling web (nginx:alpine)...
ERROR: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout

解决方法

一般都是网络问题,设置代理, 或使用国内镜像站点.

/etc/docker/daemon.json中,添加

{
  "registry-mirrors": [
    "https://registry.docker-cn.com"
  ]
}

重启服务

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
$ docker-compose up --build                                                                                                              1 ↵
Pulling web (nginx:alpine)...
alpine: Pulling from library/nginx
ff3a5c916c92: Already exists
b430473be128: Pulling fs layer
7d4e05a01906: Download complete
8aeac9a3205f: Download complete
...

参考文档


Author: Itaken
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Itaken !
  TOC目录