1、配置docker的国内加速器
docker版本为1.13.1需要配置一下daemon.json
配置阿里云的docker加速器:
1
2
3
4
5
6
|
nielinqi@Centos:~$
vim
/etc/docker/daemon
.json
{
"registry-mirrors"
: [
"https://kv3qfp85.mirror.aliyuncs.com"
]
}
|
2、拉取registry仓库docker镜像
1
|
nielinqi@Centos:~$
docker pull registry
|
3、创建registry docker进程
1
2
3
4
|
nielinqi@Centos:~$
docker run -d --privileged -p 5000:5000 --name registry --restart=always -v /myregistry:/var/lib/registry registry
ry
:
/var/lib/registry
registry
nielinqi@Centos:~$
sudo
docker
ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d8f77abe36a7 registry
"/entrypoint.sh /e..."
2 hours ago Up 2 hours 0.0.0.0:5000->5000
/tcp
registry
|
4、测试上传一个镜像
下载一个测试镜像
1
|
nielinqi@Centos:~$
sudo
docker pull busybox
|
将busybox镜像重命名为本地镜像格式与本地registry相匹配。
镜像名称由registry和tag两部分组成,registry完整格式:[registry_ip]:[registry:port]/[user]/[image_name:version]
1
|
nielinqi@Centos:~$
sudo
docker tag busybox 192.168.56.101:5000
/nielinqi/test
:v1.0
|
5、使用docker push命令上传镜像
1
|
nielinqi@Centos:~$
sudo
docker push 192.168.56.101:5000
/nielinqi/test
:v1.0
|
查看镜像
1
2
|
nielinqi@Centos:~$ curl http:
//192
.168.56.101:5000
/v2/_catalog
{
"repositories"
:[
"nielinqi/my-image"
,
"nielinqi/test"
]}
|
在此需要配置daemon.json的insecure-registries,为了解决https的报错,因为docker默认使用https协议,但是本地现在只支持http协议
不配置daemon.json的话会出现一下错误:
1
|
Get https:
//192
.168.56.101:5000
/v1/_ping
: http: server gave HTTP response to HTTPS clie
|
配置如下:
1
2
3
4
5
6
7
8
9
|
nielinqi@Centos:~$
sudo
vim
/etc/docker/daemon
.json
{
"registry-mirrors"
: [
"https://kv3qfp85.mirror.aliyuncs.com"
],
"insecure-registries"
: [
"192.168.56.101:5000"
]
}
|
重启docker进程
1
|
nielinqi@Centos:~$
sudo
systemctl restart docker
|
上传报错的问题就此解决
6、下载镜像测试一下
1
2
3
4
|
nielinqi@Centos:~$
sudo
docker pull 192.168.56.101:5000
/wangpeng/test
:v1.0
v1.0: Pulling from wangpeng
/test
Digest: sha256:73a74253ed45caebc619d95b1d84e4d67a64e5b6d81e31ac7c496b9c11128d74
Status: Image is up to
date
for
192.168.56.101:5000
/wangpeng/test
:v1.0
|