docker镜像仓库
docker 官方镜像仓库: docker hub
官网地址:https://hub.docker.com/
需要注册docker hub账户,我的dockerID:iceliooo1984
pull镜像
pull公共镜像
[root@k8s-w2 ~]# docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
Digest: sha256:996d406c509a4ebe2f4e96eeda331a354f1663b7ec0ff06685b75c4decef7325
Status: Image is up to date for tomcat:latest
[root@k8s-w2 ~]#
pull私有镜像
未登录直接pull失败
[root@k8s-w2 ~]# docker pull iceliooo1984/tomcat
Using default tag: latest
Error response from daemon: pull access denied for iceliooo1984/tomcat, repository does not exist or may require 'docker login'
[root@k8s-w2 ~]#
登录后pull成功
[root@k8s-w2 ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: iceliooo1984
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@k8s-w2 ~]# docker pull iceliooo1984/tomcat
Using default tag: latest
latest: Pulling from iceliooo1984/tomcat
Digest: sha256:8e75a9065fd732f2d06fccba994b246d77360b6e9870ac02b60b5b7d1fc6007d
Status: Downloaded n
push镜像
准备镜像
1. 通过Dockerfile生成镜像:docker build -t <hub-user>/<repo-name>[:<tag>];
2. 通过docker tag <existing-image> <hub-user>/<repo-name>[:<tag>] 重新为已存在的镜像打标签;
3. 通过 docker commit <exiting-container> <hub-user>/<repo-name>[:<tag>] 生成新的镜像。
**tag为可选,没有指定默认使用latest作为tag**
[root@k8s-w2 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest 6408fdc94212 9 days ago 507MB
nginx latest 231d40e811cd 10 days ago 126MB
hello-world latest fce289e99eb9 11 months ago 1.84kB
[root@k8s-w2 ~]# docker tag nginx iceliooo1984/nginx:bingo
[root@k8s-w2 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest 6408fdc94212 9 days ago 507MB
iceliooo1984/nginx bingo 231d40e811cd 10 days ago 126MB
nginx latest 231d40e811cd 10 days ago 126MB
hello-world latest fce289e99eb9 11 months ago 1.84kB
[root@k8s-w2 ~]#
未登录直接push,被拒绝
[root@k8s-w2 ~]# docker push iceliooo1984/nginx:bingo
The push refers to repository [docker.io/iceliooo1984/nginx]
4fc1aa8003a3: Preparing
5fb987d2e54d: Preparing
831c5620387f: Preparing
denied: requested access to the resource is denied
[root@k8s-w2 ~]#
登录docker hub,并push镜像
[root@k8s-w2 ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: iceliooo1984
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@k8s-w2 ~]# docker push iceliooo1984/nginx:bingo
The push refers to repository [docker.io/iceliooo1984/nginx]
4fc1aa8003a3: Mounted from library/nginx
5fb987d2e54d: Mounted from library/nginx
831c5620387f: Mounted from library/nginx
bingo: digest: sha256:189cce606b29fb2a33ebc2fcecfa8e33b0b99740da4737133cdbcee92f3aba0a size: 948
[root@k8s-w2 ~]#
push成功
阿里云容器镜像服务
官网地址:https://cr.console.aliyun.com/cn-shenzhen/instances/repositories
shenzhen还是hangzhou根据自己的服务器所属地区确定。
镜像加速器
使用加速器可以提升获取Docker官方镜像的速度
1. 安装/升级Docker客户端
推荐安装1.10.0以上版本的Docker客户端,参考文档 docker-ce
2. 配置镜像加速器
针对Docker客户端版本大于 1.10.0 的用户
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://XXXX.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
创建命名空间
这里创建一个私有的命名空间:iceliooo1984
设置访问凭证
这里设置一个固定密码方式的访问凭证,docker登录阿里云镜像服务时使用该凭证作为登录密码
pull镜像
由于命名空间iceliooo1984是私有的,必须登录后才能访问。
[root@k8s-w2 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
iceliooo1984/tomcat latest 6408fdc94212 9 days ago 507MB
tomcat latest 6408fdc94212 9 days ago 507MB
iceliooo1984/nginx bingo 231d40e811cd 10 days ago 126MB
nginx latest 231d40e811cd 10 days ago 126MB
hello-world latest fce289e99eb9 11 months ago 1.84kB
[root@k8s-w2 ~]# docker pull registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx
Using default tag: latest
Error response from daemon: pull access denied for registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx, repository does not exist or may require 'docker login'
[root@k8s-w2 ~]# docker login --username=阿里云账户 registry.cn-shenzhen.aliyuncs.com
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@k8s-w2 ~]# docker pull registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx
Using default tag: latest
latest: Pulling from iceliooo1984/nginx
Digest: sha256:189cce606b29fb2a33ebc2fcecfa8e33b0b99740da4737133cdbcee92f3aba0a
Status: Downloaded newer image for registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx:latest
[root@k8s-w2 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
iceliooo1984/tomcat latest 6408fdc94212 9 days ago 507MB
tomcat latest 6408fdc94212 9 days ago 507MB
iceliooo1984/nginx bingo 231d40e811cd 10 days ago 126MB
nginx latest 231d40e811cd 10 days ago 126MB
registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx latest 231d40e811cd 10 days ago 126MB
hello-world latest fce289e99eb9 11 months ago 1.84kB
[root@k8s-w2 ~]#
push镜像
准备镜像
1. 通过Dockerfile生成镜像:docker build -t <镜像服务地址><命名空间>/<repo-name>[:<tag>] ;
2. 通过docker tag <existing-image> <镜像服务地址><命名空间>/<repo-name>[:<tag>] 重新为已存在的镜像打标签;
3. 通过 docker commit <exiting-container> <镜像服务地址><命名空间>/<repo-name>[:<tag>] 生成新的镜像。
**tag为可选,没有指定默认使用latest作为tag**
[root@k8s-w2 ~]# docker tag nginx registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx:bingo
[root@k8s-w2 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
iceliooo1984/tomcat latest 6408fdc94212 9 days ago 507MB
tomcat latest 6408fdc94212 9 days ago 507MB
iceliooo1984/nginx bingo 231d40e811cd 10 days ago 126MB
nginx latest 231d40e811cd 10 days ago 126MB
registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx bingo 231d40e811cd 10 days ago 126MB
registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx latest 231d40e811cd 10 days ago 126MB
hello-world latest fce289e99eb9 11 months ago 1.84kB
[root@k8s-w2 ~]#
push镜像
由于命名空间iceliooo1984是私有的,必须登录后才能push。
退出登录,push失败
[root@k8s-w2 ~]# docker logout registry.cn-shenzhen.aliyuncs.com
Removing login credentials for registry.cn-shenzhen.aliyuncs.com
[root@k8s-w2 ~]# docker push registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx:bingo
The push refers to repository [registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx]
4fc1aa8003a3: Preparing
5fb987d2e54d: Preparing
831c5620387f: Preparing
denied: requested access to the resource is denied
[root@k8s-w2 ~]#
登录后push成功
[root@k8s-w2 ~]# docker login --username=阿里云账户 registry.cn-shenzhen.aliyuncs.com
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@k8s-w2 ~]# docker push registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx:bingo
The push refers to repository [registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx]
4fc1aa8003a3: Layer already exists
5fb987d2e54d: Layer already exists
831c5620387f: Layer already exists
bingo: digest: sha256:189cce606b29fb2a33ebc2fcecfa8e33b0b99740da4737133cdbcee92f3aba0a size: 948
[root@k8s-w2 ~]#
自己搭建Docker Harbor
访问github上的harbor项目,查看最新的release版本v1.9.3
地址:https://github.com/goharbor/harbor/releases
下载并解压
[root@k8s-w2 ~]# cd /opt
[root@k8s-w2 opt]# wget https://github.com/goharbor/harbor/releases/download/v1.9.3/harbor-offline-installer-v1.9.3.tgz
--2019-12-03 09:47:25-- https://github.com/goharbor/harbor/releases/download/v1.9.3/harbor-offline-installer-v1.9.3.tgz
Resolving github.com (github.com)... 52.74.223.119
Connecting to github.com (github.com)|52.74.223.119|:443... connected.
······
[root@k8s-w2 opt]# ll
total 620080
drwx--x--x. 4 root root 28 Dec 2 10:20 containerd
-rw-r--r--. 1 root root 634959522 Dec 2 15:15 harbor-offline-installer-v1.9.3.tgz
[root@k8s-w2 opt]# tar -zxvf harbor-offline-installer-v1.9.3.tgz
harbor/harbor.v1.9.3.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/harbor.yml
[root@k8s-w2 opt]#
修改配置文件
修改harbor.yml文件第5行,为本机ip
-rw-r--r--. 1 root root 634959522 Dec 2 15:15 harbor-offline-installer-v1.9.3.tgz
[root@k8s-w2 opt]# cd harbor/
[root@k8s-w2 harbor]# ll
total 623364
-rw-r--r--. 1 root root 638288840 Nov 14 11:23 harbor.v1.9.3.tar.gz
-rw-r--r--. 1 root root 5805 Nov 14 11:23 harbor.yml
-rwxr-xr-x. 1 root root 5088 Nov 14 11:23 install.sh
-rw-r--r--. 1 root root 11347 Nov 14 11:23 LICENSE
-rwxr-xr-x. 1 root root 1748 Nov 14 11:23 prepare
[root@k8s-w2 harbor]# vi harbor.yml
1 # Configuration file of Harbor
2
3 # The IP address or hostname to access admin UI and registry service.
4 # DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
5 hostname: 192.168.56.212
安装
由于Docker Harbor需要docker-compose进行单机多容器管理,需要先安装docker-compose
安装docker-compose
官网地址:https://docs.docker.com/compose/install/#install-compose
安装目前最新版本v1.25.0
[root@k8s-w2 harbor]# sudo curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 617 0 617 0 0 204 0 --:--:-- 0:00:03 --:--:-- 204
100 16.2M 100 16.2M 0 0 142k 0 0:01:56 0:01:56 --:--:-- 97k
# 赋予执行权限
[root@k8s-w2 harbor]# chmod +x /usr/local/bin/docker-compose
# 查看版本
[root@k8s-w2 harbor]# docker-compose --version
docker-compose version 1.25.0, build 0a186604
[root@k8s-w2 harbor]#
安装Docker Harbor
[root@k8s-w2 harbor]# ./install.sh
[Step 0]: checking installation environment ...
Note: docker version: 18.09.9
Note: docker-compose version: 1.25.0
[Step 1]: loading Harbor images ...
47a4bb1cfbc7: Loading layer [==================================================>] 34.26MB/34.26MB
f93c083be5bc: Loading layer [==================================================>] 9.009MB/9.009MB
bf1b03029526: Loading layer [==================================================>] 44.41MB/44.41MB
3395eb0db37a: Loading layer [==================================================>] 2.048kB/2.048kB
630606b67737: Loading layer [==================================================>] 3.072kB/3.072kB
b59ccb3639e4: Loading layer [==================================================>] 44.41MB/44.41MB
Loaded image: goharbor/chartmuseum-photon:v0.9.0-v1.9.3
0801a4e2ebe9: Loading layer [==================================================>] 2.56kB/2.56kB
e2b8ec162f1b: Loading layer [==================================================>] 1.536kB/1.536kB
b68f30fd6125: Loading layer [==================================================>] 73.35MB/73.35MB
fbe2002fa9e6: Loading layer [==================================================>] 42.63MB/42.63MB
105f3dfa58eb: Loading layer [==================================================>] 156.7kB/156.7kB
2395dbeaea9f: Loading layer [==================================================>] 3.006MB/3.006MB
Loaded image: goharbor/prepare:v1.9.3
e80aab7b0662: Loading layer [==================================================>] 63.49MB/63.49MB
f8b3d119e8a9: Loading layer [==================================================>] 54.42MB/54.42MB
5f496dd4633b: Loading layer [==================================================>] 5.632kB/5.632kB
9a2858fea72d: Loading layer [==================================================>] 2.048kB/2.048kB
b7501a88cd95: Loading layer [==================================================>] 2.56kB/2.56kB
c82e3969a2e2: Loading layer [==================================================>] 2.56kB/2.56kB
7cac869555ad: Loading layer [==================================================>] 2.56kB/2.56kB
cca577be763d: Loading layer [==================================================>] 10.24kB/10.24kB
Loaded image: goharbor/harbor-db:v1.9.3
9a508de7d2b7: Loading layer [==================================================>] 9.005MB/9.005MB
508382d944be: Loading layer [==================================================>] 3.072kB/3.072kB
6e9e3cb5d33e: Loading layer [==================================================>] 2.56kB/2.56kB
73ddaf5bf2d0: Loading layer [==================================================>] 21.76MB/21.76MB
9a276490655f: Loading layer [==================================================>] 21.76MB/21.76MB
Loaded image: goharbor/registry-photon:v2.7.1-patch-2819-2553-v1.9.3
4a0251807cc9: Loading layer [==================================================>] 9.004MB/9.004MB
897af7ff7b63: Loading layer [==================================================>] 6.239MB/6.239MB
3f4123d93010: Loading layer [==================================================>] 14.9MB/14.9MB
4e0bdb09cba5: Loading layer [==================================================>] 29.21MB/29.21MB
29c5283b24ee: Loading layer [==================================================>] 22.02kB/22.02kB
6f09075fda1a: Loading layer [==================================================>] 50.34MB/50.34MB
Loaded image: goharbor/notary-signer-photon:v0.6.1-v1.9.3
756ffb58fa91: Loading layer [==================================================>] 7.037MB/7.037MB
733009a88a23: Loading layer [==================================================>] 196.6kB/196.6kB
5cc05e9a6a60: Loading layer [==================================================>] 172kB/172kB
eabe1b3a567b: Loading layer [==================================================>] 15.36kB/15.36kB
dd83cfe76436: Loading layer [==================================================>] 3.584kB/3.584kB
28bde9e732c9: Loading layer [==================================================>] 10.84MB/10.84MB
Loaded image: goharbor/harbor-portal:v1.9.3
0eb10921ee80: Loading layer [==================================================>] 78.25MB/78.25MB
74a7ce2b0571: Loading layer [==================================================>] 3.072kB/3.072kB
7d193a1c54ab: Loading layer [==================================================>] 59.9kB/59.9kB
d45413cea5ea: Loading layer [==================================================>] 61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v1.9.3
7c53cafac35a: Loading layer [==================================================>] 337.9MB/337.9MB
c6bad7449208: Loading layer [==================================================>] 119.8kB/119.8kB
Loaded image: goharbor/harbor-migrator:v1.9.3
4bb3c8da2619: Loading layer [==================================================>] 50.3MB/50.3MB
fa60bb5fba7f: Loading layer [==================================================>] 3.584kB/3.584kB
12a81f321c68: Loading layer [==================================================>] 3.072kB/3.072kB
a94dcd551900: Loading layer [==================================================>] 2.56kB/2.56kB
c684117da188: Loading layer [==================================================>] 3.072kB/3.072kB
f14e11ea2c25: Loading layer [==================================================>] 3.584kB/3.584kB
2e2e439cb618: Loading layer [==================================================>] 12.29kB/12.29kB
Loaded image: goharbor/harbor-log:v1.9.3
99ce145e19e6: Loading layer [==================================================>] 10.84MB/10.84MB
Loaded image: goharbor/nginx-photon:v1.9.3
da7ad744c6fd: Loading layer [==================================================>] 16.4MB/16.4MB
a03cee9d5ed3: Loading layer [==================================================>] 29.21MB/29.21MB
f5f37ba098b1: Loading layer [==================================================>] 22.02kB/22.02kB
c6e237d0effb: Loading layer [==================================================>] 51.85MB/51.85MB
Loaded image: goharbor/notary-server-photon:v0.6.1-v1.9.3
01d39dbfbd65: Loading layer [==================================================>] 115.7MB/115.7MB
6d1186763503: Loading layer [==================================================>] 12.31MB/12.31MB
293c8dc3d8c6: Loading layer [==================================================>] 2.048kB/2.048kB
d0ffe0bb8b6b: Loading layer [==================================================>] 48.13kB/48.13kB
c9f0ab7d8bbb: Loading layer [==================================================>] 3.072kB/3.072kB
75c4044a879b: Loading layer [==================================================>] 12.36MB/12.36MB
Loaded image: goharbor/clair-photon:v2.1.0-v1.9.3
b2329d5f99cf: Loading layer [==================================================>] 12.77MB/12.77MB
17c27eb4f7f8: Loading layer [==================================================>] 55.4MB/55.4MB
3c10f4815fc0: Loading layer [==================================================>] 5.632kB/5.632kB
5fb810768754: Loading layer [==================================================>] 36.35kB/36.35kB
376871497fae: Loading layer [==================================================>] 55.4MB/55.4MB
Loaded image: goharbor/harbor-core:v1.9.3
2c38bb39e841: Loading layer [==================================================>] 12.77MB/12.77MB
20ef2473aa7f: Loading layer [==================================================>] 48.13MB/48.13MB
Loaded image: goharbor/harbor-jobservice:v1.9.3
bc526ee3d965: Loading layer [==================================================>] 9.005MB/9.005MB
d880cff24505: Loading layer [==================================================>] 3.072kB/3.072kB
adc7407dd64d: Loading layer [==================================================>] 21.76MB/21.76MB
aa1f551082be: Loading layer [==================================================>] 3.072kB/3.072kB
97bd8288c3d1: Loading layer [==================================================>] 8.661MB/8.661MB
f184a9da0594: Loading layer [==================================================>] 30.42MB/30.42MB
Loaded image: goharbor/harbor-registryctl:v1.9.3
[Step 2]: preparing environment ...
prepare base dir is set to /opt/harbor
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /secret/keys/secretkey
Generated certificate, key file: /secret/core/private_key.pem, cert file: /secret/registry/root.crt
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
[Step 3]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating redis ... done
Creating registryctl ... done
Creating harbor-portal ... done
Creating registry ... done
Creating harbor-db ... done
Creating harbor-core ... done
Creating harbor-jobservice ... done
Creating nginx ... done
✔ ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://192.168.56.212.
For more details, please visit https://github.com/goharbor/harbor .
[root@k8s-w2 harbor]#
成功访问
push镜像
准备镜像
1. 通过Dockerfile生成镜像:docker build -t <ip:port>/<项目>/<repo-name>[:<tag>];
2. 通过docker tag <existing-image> <hub-user>/<repo-name>[:<tag>] 重新为已存在的镜像打标签;
3. 通过 docker commit <exiting-container> <hub-user>/<repo-name>[:<tag>] 生成新的镜像。
**tag为可选,没有指定默认使用latest作为tag**
新建私有项目dev
[root@k8s-w2 harbor]# docker tag nginx 192.168.56.212/dev/nginx
[root@k8s-w2 harbor]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
iceliooo1984/tomcat latest 6408fdc94212 9 days ago 507MB
tomcat latest 6408fdc94212 9 days ago 507MB
iceliooo1984/nginx bingo 231d40e811cd 10 days ago 126MB
nginx latest 231d40e811cd 10 days ago 126MB
registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx bingo 231d40e811cd 10 days ago 126MB
registry.cn-shenzhen.aliyuncs.com/iceliooo1984/nginx latest 231d40e811cd 10 days ago 126MB
192.168.56.212/dev/nginx latest 231d40e811cd 10 days ago 126MB
push镜像
失败,不支持https访问
[root@k8s-w2 harbor]# docker push 192.168.56.212/dev/nginx
The push refers to repository [192.168.56.212/dev/nginx]
Get https://192.168.56.212/v2/: dial tcp 192.168.56.212:443: connect: connection refused
[root@k8s-w2 harbor]#
添加 insecure-registries
systemctl daemon-reload
[root@k8s-w2 harbor]# vi /etc/docker/daemon.json
{
"insecure-registries": ["192.168.56.212"],
"registry-mirrors": ["https://q1y2usc7.mirror.aliyuncs.com"]
}
[root@k8s-w2 harbor]# systemctl daemon-reload
[root@k8s-w2 harbor]# systemctl restart docker
[root@k8s-w2 harbor]# docker push 192.168.56.212/dev/nginx
The push refers to repository [192.168.56.212/dev/nginx]
登录后push成功
用户:admin 默认密码:Harbor12345
[root@k8s-w2 harbor]# docker login 192.168.56.212
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@k8s-w2 harbor]# docker push 192.168.56.212/dev/nginx
The push refers to repository [192.168.56.212/dev/nginx]
4fc1aa8003a3: Pushed
5fb987d2e54d: Pushed
831c5620387f: Pushed
latest: digest: sha256:189cce606b29fb2a33ebc2fcecfa8e33b0b99740da4737133cdbcee92f3aba0a size: 948
[root@k8s-w2 harbor]#
pull镜像
在另一条服务器上pull刚上传的镜像
同样需要配置insecure-registries
[root@k8s-w1 ~]# docker pull 192.168.56.212/dev/nginx
Using default tag: latest
Error response from daemon: Get https://192.168.56.212/v2/: dial tcp 192.168.56.212:443: connect: connection refused
[root@k8s-w1 ~]# vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://q1y2usc7.mirror.aliyuncs.com"],
"insecure-registries": ["192.168.56.210","192.168.56.212"]
}
[root@k8s-w1 ~]# systemctl daemon-reload
[root@k8s-w1 ~]# systemctl restart docker
[root@k8s-w1 ~]# docker pull 192.168.56.212/dev/nginx
Using default tag: latest
Error response from daemon: pull access denied for 192.168.56.212/dev/nginx, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
由于项目是私有的,需要登录才能pull
[root@k8s-w1 ~]# docker login 192.168.56.212
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@k8s-w1 ~]# docker pull 192.168.56.212/dev/nginx
Using default tag: latest
latest: Pulling from dev/nginx
000eee12ec04: Pull complete
eb22865337de: Pull complete
bee5d581ef8b: Pull complete
Digest: sha256:189cce606b29fb2a33ebc2fcecfa8e33b0b99740da4737133cdbcee92f3aba0a
Status: Downloaded newer image for 192.168.56.212/dev/nginx:latest
192.168.56.212/dev/nginx:latest
[root@k8s-w1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.56.212/dev/nginx latest 231d40e811cd 10 days ago 126MB
[root@k8s-w1 ~]#