docker hub镜像上传
[root@sunrui ~]
[root@sunrui docker]
{ "registry-mirrors":
["https://registry.docker-cn.com"]
}
[root@sunrui docker]
[root@sunrui docker]
[root@sunrui ~]
Username: sunrui12138
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/
[root@sunrui ~]
Sending build context to Docker daemon 865.3kB
Step 1/3 : FROM scratch
--->
Step 2/3 : COPY hello /
---> 2322533b4210
Step 3/3 : CMD ["/hello"]
---> Running in 5994e2099b8d
Removing intermediate container 5994e2099b8d
---> 32fedb0d83ba
Successfully built 32fedb0d83ba
Successfully tagged sunrui12138/testdocker:latest
[root@sunrui ~]
[root@sunrui ~]
REPOSITORY TAG IMAGE ID CREATED SIZE
sunrui12138/testdocker 22.03 32fedb0d83ba About a minute ago 861kB
sunrui12138/testdocker latest 32fedb0d83ba About a minute ago 861kB
[root@sunrui ~]
The push refers to repository [docker.io/sunrui2138/testdocker]
88dc11111fec: Pushed
22.03: digest: sha256:c9225ad48cb94c8f160e839187e81ce28f85dbff8316e7443879f5169f41cfb0 size: 527
[仓库地址](https://hub.docker.com/repository/docker/sunrui12138/testdocker)
docker容器生成镜像提交给hub
[root@sunrui ~]
sha256:a4b85b3fb73e23e75440430252477b77aee8927fdf9495160297b86dcf5f917c
[root@sunrui ~]
REPOSITORY TAG IMAGE ID CREATED SIZE
sunrui12138/ubuntu 22.03 a4b85b3fb73e 6 seconds ago 72.8MB
[root@sunrui ~]
The push refers to repository [docker.io/sunrui12138/ubuntu]
b954f8dfd459: Pushed
9f54eef41275: Mounted from library/ubuntu
22.03: digest: sha256:573bc189eba09934db466a2344edee5f46cd7d98fb765690b4ba7b1e9dd26624 size: 736
[仓库地址](https://hub.docker.com/repository/docker/sunrui12138/ubuntu)
docker注册中心
[阿里云官网地址](https://www.aliyun.com)
[root@sunrui ~]
Removing login credentials for https://index.docker.io/v1/
[root@sunrui ~]
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/
Login Succeeded
[root@sunrui ~]
Sending build context to Docker daemon 865.3kB
Step 1/3 : FROM scratch
--->
Step 2/3 : COPY hello /
---> Using cache
---> 846e09a540e6
Step 3/3 : CMD ["/hello"]
---> Using cache
---> a5dbf1d93254
Successfully built a5dbf1d93254
Successfully tagged registry.cn-hangzhou.aliyuncs.com/sunrui/docker_test:22.03
[root@sunrui ~]
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/sunrui/docker_test]
88dc11111fec: Pushed
22.03: digest: sha256:b1d135c19b018cfbbba32085948cb125507b508549a8296568c25a81f5b0709b size: 527
docker自建注册中心
基于容器安装运行Registry
[root@sunrui ~]
Using default tag: latest
latest: Pulling from library/registry
3d2430473443: Pull complete
5bf98bf80c2f: Pull complete
950c199aa45b: Pull complete
92504897768b: Pull complete
c6488f74dce8: Pull complete
Digest: sha256:65be6503496c34ec234e89a831ca248b18c2e04c800d9d74af73866e3cda8578
Status: Downloaded newer image for registry:latest
docker.io/library/registry:latest
[root@sunrui ~]
3cac187c798b08d12da5f292a03621e2e27021763481e9313b6f7de57a722354
[root@sunrui ~]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3cac187c798b registry "/entrypoint.sh /etc…" 29 seconds ago Up 28 seconds 0.0.0.0:5000->5000/tcp myregistry
[root@sunrui ~]
{"repositories":[]}
将镜像上传到自建的注册中心
[root@sunrui ~]
[root@sunrui ~]
REPOSITORY TAG IMAGE ID CREATED SIZE
sunrui12138/ubuntu 22.03 93a86f5131ec 3 hours ago 72.8MB
127.0.0.1:5000/ubuntu v1 ba6acccedd29 5 months ago 72.8MB
ubuntu latest ba6acccedd29 5 months ago 72.8MB
[root@sunrui ~]
[root@sunrui ~]
The push refers to repository [127.0.0.1:5000/ubuntu]
9f54eef41275: Pushed
v1: digest: sha256:7cc0576c7c0ec2384de5cbf245f41567e922aab1b075f3e8ad565f508032df17 size: 529
[root@sunrui ~]
The push refers to repository [127.0.0.1:5000/testdocker]
88dc11111fec: Pushed
v1: digest: sha256:b1d135c19b018cfbbba32085948cb125507b508549a8296568c25a81f5b0709b size: 527
[root@sunrui ~]
{"repositories":["testdocker","ubuntu"]}
从自建注册中心下载镜像
[root@sunrui ~]
Untagged: 127.0.0.1:5000/testdocker:v1
Untagged: 127.0.0.1:5000/testdocker@sha256:b1d135c19b018cfbbba32085948cb125507b508549a8296568c25a81f5b0709b
[root@sunrui ~]
v1: Pulling from testdocker
Digest: sha256:b1d135c19b018cfbbba32085948cb125507b508549a8296568c25a81f5b0709b
Status: Downloaded newer image for 127.0.0.1:5000/testdocker:v1
127.0.0.1:5000/testdocker:v1
[root@sunrui ~]
REPOSITORY TAG IMAGE ID CREATED SIZE
127.0.0.1:5000/testdocker v1 a5dbf1d93254 3 hours ago 861kB
配置注册中心地址
本地服务器情况下使用127.0.0.1或者localhost作为注册中心地址都是可以的。
但如果使用主机的域名或IP地址提供服务,会报错,这是因为1.3版本后,docker注册中心默认使用的https,但是搭建私有注册中心默认使用的是http。
解决方法:修改docker客户端/etc/docker/daemon.json文件,将地址添加到insecure-registries列表中,允许不安全的通信即可。
{
"insecure-registries":["192.168.100.10:5000"]
}
systemctl restart docker
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)