1.docker 实例
ip | hostname |
---|---|
192.168.1.180 | basenode |
192.168.1.151 | bigdata01.com |
在192.168.1.151 服务网器上拉去私服运行私服
docker 私服官网 https://hub.docker.com/_/registry
2. 拉去私服 : docker pull registry
3. 运行容器 :
docker run -itd -p 5000:5000 --name registry --restart=always registry:2.7.1
[root@bigdata01 ~]# docker run -itd -p 5000:5000 --name registry --restart=always registry:2.7.1
a978b3ffff45ff79bfa5bdc7a58ef1fd9ddca53cdc9e358c823041ba696c40e5
[root@bigdata01 ~]#
4.(192.168.1.180) 将另外一台机器的容器推送到私服
4.1 推送镜像 docker tag nginx:latest 192.168.1.151:5000/nginx:v1
[root@basenode ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest b0e0b0a92cf9 2 weeks ago 680MB
mysql latest ecac195d15af 2 weeks ago 516MB
mongo latest fefd78e9381a 2 weeks ago 699MB
redis latest 7faaec683238 3 weeks ago 113MB
nginx latest 87a94228f133 3 weeks ago 133MB
centos 7 eeb6ee3f44bd 7 weeks ago 204MB
tomcat 7 9dfd74e6bc2f 4 months ago 533MB
registry.cn-hangzhou.aliyuncs.com/anoy/yapi latest 76d11bb7c386 22 months ago 170MB
centos/mysql-57-centos7 latest f83a2938370c 2 years ago 452MB
[root@basenode ~]# docker tag nginx:latest 192.168.1.151:5000/nginx:v1
[root@basenode ~]#
5. 在另外一台机器中查看镜像 (192.168.1.151)
多了刚才的nginx 镜像
[root@bigdata01 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mongo latest fefd78e9381a 2 weeks ago 699MB
nginx latest 87a94228f133 3 weeks ago 133MB
registry 2.7.1 b2cb11db9d3d 2 months ago 26.2MB
registry.cn-hangzhou.aliyuncs.com/anoy/yapi latest 76d11bb7c386 22 months ago 170MB
[root@bigdata01 ~]#
6. 在主节点添加内容 将https 修改为http 的方式进行访问(192.168.1.180 中修改)
编辑配置文件
vi /etc/docker/daemon.json
增加仓库配置信息
{ "insecure-registries":["192.168.1.151:5000"] }
重启docker
systemctl daemon-reload
systemctl restart docker
查看docker信息确认仓库是否添加
docker info
如下
[root@basenode ~]# vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],
"insecure-registries":["192.168.1.151:5000"]
}
6.1 重启docker 服务 (192.168.1.180 中修改)
[root@basenode ~]# docker tag nginx:latest 192.168.1.151:5000/nginx:v1
[root@basenode ~]# vi /etc/docker/daemon.json
[root@basenode ~]# systemctl daemon-reload
[root@basenode ~]# systemctl restart docker
[root@basenode ~]# docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.6.1-docker)
scan: Docker Scan (Docker Inc., v0.8.0)
Server:
Containers: 17
Running: 2
Paused: 0
Stopped: 15
Images: 9
Server Version: 20.10.8
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: e25210fe30a0a703442421b0f60afac609f950a3
runc version: v1.0.1-0-g4144b63
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1160.42.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 8.342GiB
Name: basenode
ID: FATL:22DL:VDHP:O4HW:EGD4:2YZT:2VAB:PUCK:5XWL:VKMR:IN6P:J44Z
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
192.168.1.151:5000
127.0.0.0/8
Registry Mirrors:
https://docker.mirrors.ustc.edu.cn/
Live Restore Enabled: false
[root@basenode ~]#
6.2 将nginx 推送到私服 docker push 192.168.1.151:5000/nginx:v1
(192.168.1.180 中操作)
[root@basenode ~]# docker push 192.168.1.151:5000/nginx:v1
The push refers to repository [192.168.1.151:5000/nginx]
9959a332cf6e: Pushed
f7e00b807643: Pushed
f8e880dfc4ef: Pushed
788e89a4d186: Pushed
43f4e41372e4: Pushed
e81bff2725db: Pushed
v1: digest: sha256:7250923ba3543110040462388756ef099331822c6172a050b12c7a38361ea46f size: 1570
[root@basenode ~]#
在这里插入图片描述
查看详信息 :
http://192.168.1.151:5000/v2/nginx/tags/list
在这里插入图片描述
7.下载镜像 (192.168.1.180 中删除)
删除原来的镜像
docker rmi -f nginx:latest 192.168.1.151:5000/nginx:v1
在进行拉去 :docker pull 192.168.1.151:5000/nginx:v1
[root@basenode ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest b0e0b0a92cf9 2 weeks ago 680MB
mysql latest ecac195d15af 2 weeks ago 516MB
mongo latest fefd78e9381a 2 weeks ago 699MB
redis latest 7faaec683238 3 weeks ago 113MB
192.168.1.151:5000/nginx v1 87a94228f133 3 weeks ago 133MB
nginx latest 87a94228f133 3 weeks ago 133MB
centos 7 eeb6ee3f44bd 7 weeks ago 204MB
tomcat 7 9dfd74e6bc2f 4 months ago 533MB
registry.cn-hangzhou.aliyuncs.com/anoy/yapi latest 76d11bb7c386 22 months ago 170MB
centos/mysql-57-centos7 latest f83a2938370c 2 years ago 452MB
[root@basenode ~]# docker rmi -f nginx:latest 192.168.1.151:5000/nginx:v1
Untagged: nginx:latest
Untagged: nginx@sha256:644a70516a26004c97d0d85c7fe1d0c3a67ea8ab7ddf4aff193d9f301670cf36
Untagged: 192.168.1.151:5000/nginx:v1
Untagged: 192.168.1.151:5000/nginx@sha256:7250923ba3543110040462388756ef099331822c6172a050b12c7a38361ea46f
Deleted: sha256:87a94228f133e2da99cb16d653cd1373c5b4e8689956386c1c12b60a20421a02
[root@basenode ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest b0e0b0a92cf9 2 weeks ago 680MB
mysql latest ecac195d15af 2 weeks ago 516MB
mongo latest fefd78e9381a 2 weeks ago 699MB
redis latest 7faaec683238 3 weeks ago 113MB
centos 7 eeb6ee3f44bd 7 weeks ago 204MB
tomcat 7 9dfd74e6bc2f 4 months ago 533MB
registry.cn-hangzhou.aliyuncs.com/anoy/yapi latest 76d11bb7c386 22 months ago 170MB
centos/mysql-57-centos7 latest f83a2938370c 2 years ago 452MB
[root@basenode ~]# docker pull 192.168.1.151:5000/nginx:v1
v1: Pulling from nginx
b380bbd43752: Already exists
fca7e12d1754: Already exists
745ab57616cb: Already exists
a4723e260b6f: Already exists
1c84ebdff681: Already exists
858292fd2e56: Already exists
Digest: sha256:7250923ba3543110040462388756ef099331822c6172a050b12c7a38361ea46f
Status: Downloaded newer image for 192.168.1.151:5000/nginx:v1
192.168.1.151:5000/nginx:v1
[root@basenode ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest b0e0b0a92cf9 2 weeks ago 680MB
mysql latest ecac195d15af 2 weeks ago 516MB
mongo latest fefd78e9381a 2 weeks ago 699MB
redis latest 7faaec683238 3 weeks ago 113MB
192.168.1.151:5000/nginx v1 87a94228f133 3 weeks ago 133MB
centos 7 eeb6ee3f44bd 7 weeks ago 204MB
tomcat 7 9dfd74e6bc2f 4 months ago 533MB
registry.cn-hangzhou.aliyuncs.com/anoy/yapi latest 76d11bb7c386 22 months ago 170MB
centos/mysql-57-centos7 latest f83a2938370c 2 years ago 452MB
[root@basenode ~]#
网友评论