centos利用nexus搭建局域网docker私有仓库

centos利用nexus搭建局域网docker私有仓库

1、官网下载nexus oss版本

https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.29.2-02-unix.tar.gz

[root@localhost bin]# wget https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.29.2-02-unix.tar.gz
2、安装nexus以及docker
[root@localhost bin]# tar -zxvf nexus-3.29.2-02-unix.tar.gz 
[root@localhost bin]# yum install -y docker
3、运行nexus ,如果提示JAVA_HOME没有设置,请安装java的JDK环境
[root@localhost bin]# cd /opt/nexus-3.29.2-02/bin/
[root@localhost bin]# ./nexus start
WARNING: ************************************************************
WARNING: Detected execution as "root" user.  This is NOT recommended!
WARNING: ************************************************************
Starting nexus

在这里插入图片描述

4、创建docker仓库

在这里插入图片描述

hosted – 宿主仓库,用户可以 deploy 到 hosted 中,也可以手工上传构件到 hosted 里,在 central repository 是获取不到的,就需要手工上传到hosted里
在这里插入图片描述
在这里插入图片描述

5、修改docker配置,重启docker

在/etc/docker/daemon.json文件中添加下面的内容:

[root@localhost ~]# cat /etc/docker/daemon.json
{
  "insecure-registries":["10.4.7.23:8082"]
}
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker info
Insecure Registries:
10.4.7.23:8082 #生效了
 127.0.0.0/8
6、拉取并上传docker镜像
[root@localhost ~]# docker login 10.4.7.23:8082  //username:admin password:admin123
Username (admin): admin
Password: 
Login Succeeded
[root@localhost ~]# docker pull nginx                                                 //从官网下载docker镜像
[root@localhost ~]# docker tag nginx 10.4.7.23:8082/nginx:1.0
[root@localhost ~]# docker push 10.4.7.23:8082/nginx:1.0
[root@localhost ~]# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
10.4.7.23:8082/nginx   1.0                 f6d0b4767a6c        2 weeks ago         133 MB
docker.io/nginx        latest              f6d0b4767a6c        2 weeks ago         133 MB
[root@localhost ~]# docker push 10.4.7.23:8082/nginx:1.0                              //将镜像上传至本地仓库

7、查看局域网私有仓库

在这里插入图片描述

8、从私有仓库拉取镜像
[root@localhost ~]# docker pull 10.4.7.23:8082/nginx:1.0                      //从私有仓库拉取docker镜像
Trying to pull repository 10.4.7.23:8082/nginx ... 
1.0: Pulling from 10.4.7.23:8082/nginx
a076a628af6f: Pull complete 
0732ab25fa22: Pull complete 
d7f36f6fe38f: Pull complete 
f72584a26f32: Pull complete 
7125e4df9063: Pull complete 
Digest: sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8
Status: Downloaded newer image for 10.4.7.23:8082/nginx:1.0
[root@localhost ~]# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
10.4.7.23:8082/nginx   1.0                 f6d0b4767a6c        2 weeks ago         133 MB

10.4.7.23:8082/nginx 1.0 f6d0b4767a6c 2 weeks ago 133 MB


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值