本偏描述了最近通过docker搭建nexus3用于docker私服仓库

nexus搭建docker私服

nexus3部署

# 创建目录
mkdir -p /home/nexus/nexus-data
# 授权目录
chmod 777 /home/nexus/nexus-data

#拉取镜像
docker pull sonatype/nexus3

# 部署 
docker run -d -p 8081:8081 -p 8082:8082 -p 8083:8083 -v /home/nexus/nexus-data:/nexus-data --name nexus sonatype/nexus3

登录验证

http://192.168.2.93:8081

nexus部署异常

mkdir: cannot create directory '../sonatype-work/nexus3/log': Permission denied
mkdir: cannot create directory '../sonatype-work/nexus3/tmp': Permission denied

授权目录访问权限 chmod 777 dir

nexus docker仓库配置

nexus3部署配置 参考

网易镜像地址:http://hub-mirror.c.163.com docker-hosted docker-proxy docker-group

realms

docker配置文件修改

daemon.json配置

{
  "registry-mirrors" : [
    "http://ovfftd6p.mirror.aliyuncs.com",
    "http://registry.docker-cn.com",
    "http://docker.mirrors.ustc.edu.cn",
    "http://hub-mirror.c.163.com"
  ],
  # 解决不允许http协议访问
  "insecure-registries": ["http://192.168.2.93:8082",
  "http://192.168.2.93:8082", "http://192.168.2.93:8083", "http://hub-mirror.c.163.com"]
}

重启nexus

systemctl daemon-reload && systemctl restart docker 

docker start nexus

通过私服拉取镜像

拉取镜像 错误

no basic auth credentials
# docker 登录
docker login 192.168.2.93:8083
#拉取镜像
docker pull 192.168.2.93:8083/redis

==注意此处的端口号为8083,maven中的应该配置为8082==

上传

docker删除多个相同id的镜像

docker image rm $(docker images|grep 808|grep nginx| awk '{print $1,$2}'|sed  's/ /:/g')

基于原有的docker镜像打包的镜像id是一样的,删除格式为imageName:version