使用容器安装Nexus3

1.下载nexus3的镜像:

docker pull sonatype/nexus3

2.使用镜像启动一个容器:

docker run -d -p 8081:8081 -p 5000:5000 --name nexus3 -v /nexus-data:/nexus-data/ --restart=always sonatype/nexus3

要是启动不起来有可能是/nexus-data目录没有权限,把目录权限改为757

注:5000端口是用于镜像仓库的服务端口   8081 端口是nexus的服务端口

3.启动之后我们就可以通过http://服务器IP:8081访问。

默认账号密码为admin/admin123

创建Docker私有仓库

通过浏览器访问Nexus: 
http://服务器IP:8081

点击右上角进行登录,通过初始用户名和密码进行登录(admin/admin123):

点击设置界面,选择Repositories,点击Create repository,如下图所示:

选择仓库类型,这里Docker有三种类型,分别是group、hosted、proxy。这里只演示hosted类型,所以选择docker(hosted),如下图:

注:Docker镜像仓库类型含义解释如下:
  hosted : 本地存储,即同docker官方仓库一样提供本地私服功能

  proxy : 提供代理其他仓库的类型,如docker中央仓库

  group : 组类型,实质作用是组合多个仓库为一个地址

指定docker仓库的名称、指定一个端口用来通过http的方式进行访问仓库、勾选是否支持docker API V1,然后create repository;
Force basic authentication:这里最好也勾选

因为我们测试的时候不是使用加密的HTTPS进行访问,所以这里需要增加一个docker的启动参数,给他指定私库的地址,如下:

编辑/etc/docker/daemon.json 增加如下内容,当然也可通过启动参数增加,如果出现response https等错误,把http://去掉。

{

........, 
  "insecure-registries":["http://172.xx.xx.60:5000"]

}

重启docker进程: systemctl restart docker

查看docker信息: docker info ,有如下输出即正常

OSType: linux
Architecture: x86_64
Number of Docker Hooks:
CPUs:
Total Memory: 62.25 GiB
Name: .novalocal
ID: I4YA:R77P:4MMX:V76S:NL4J:XP42:WZFR:5UFD:QRNT:N4GD:54UV:KFXS
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Experimental: false
Insecure Registries:
172.xx.xx.60:
127.0.0.0/
Registry Mirrors:
https://aj2rgad5.mirror.aliyuncs.com
Live Restore Enabled: false
Registries: docker.io (secure)

登录私库

要使用私库进行上传下载需要进行登录连接到Nexus(物理机重启推拉不了镜像要重新docker logiin)

  docker login http://172.xx.xx.60:5000/

Docker上传镜像到私库

使用docker tag 对镜像进行管理(必须进行此项操作)

  docker tag使用格式:

    docker tag SOURCE_IMAGE[:TAG]  TARGET_IMAGE[:TAG]

  docker tag helolo-world 172.xx.xx.60:5000/hello:v1

  docker push 172.xx.xx.60:5000/hello:v1

示例:使用tag进行打标,正常上传的结果

[root@ docker]# docker pull 172.xx.xx.60:/hello:v1
Trying to pull repository .xx.xx.:/hello ...
v1: Pulling from 172.xx.xx.60:/hello
Digest: sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a
Status: Image is up to date for .xx.xx.:/hello:v1

不进行tag打标,会出现denied: requested access to the resource is denied报错

查看镜像

[root@ docker]# curl http://172.xx.xx.60:5000/v2/_catalog
{"repositories":["hello"]}
[root@ docker]#
[root@ ~]# curl http://172.xx.xx.60:5000/v2/hello/tags/list
{"name":"hello","tags":["v1"]}
[root@ ~]#

上传完成后,在nexus中对应的docker库中,即可看到此镜像

下载私库中的镜像

1、删除本地上例实验中的镜像(docker rmi 172.xx.xx.60:5000/hello:v1)

[root@ ~]# docker rmi .xx.xx.:/hello:v1
Untagged: .xx.xx.:/hello:v1
Untagged: .xx.xx.:/hello@sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a
[root@ ~]#

2、docker pull 172.xx.xx.60:5000/hello:v1

[root@ ~]# docker pull .xx.xx.:/hello:v1
Trying to pull repository .xx.xx.:/hello ...
v1: Pulling from .xx.xx.:/hello
Digest: sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a
Status: Downloaded newer image for .xx.xx.:/hello:v1
[root@ ~]#

删除私库中的镜像

命令有时候不灵通curl -I -X DELETE http://172.xx.xx.60:5000/v2/hello/manifests/sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a

可以回到浏览器Browse server里面删除

转摘:https://www.cnblogs.com/jihongjun/p/8968901.html

docker+Nexus Repository Manager 搭建私有docker仓库的更多相关文章

  1. 使用 Nexus Repository Manager 搭建私有docker仓库

    使用容器安装Nexus3 1.下载nexus3的镜像: docker pull sonatype/nexus3 2.使用镜像启动一个容器: docker run -d --name nexus  -- ...

  2. 【Docker】(4)搭建私有镜像仓库

    [Docker](4)搭建私有镜像仓库 说明 1. 这里是通过阿里云,搭建Docker私有镜像仓库. 2. 这里打包的镜像是从官网拉下来的,并不是自己项目创建的新镜像,主要测试功能 一.搭建过程 首先 ...

  3. 使用 Nexus Repository Manager 搭建 npm 私服

    目录 环境 下载与安装 添加npm仓库 配置与验证npm仓库 发布自己的包 Nexus开启启动 脚注 环境 windows10(1803) Nexus Repository Manager OSS 3 ...

  4. [转] 使用HTTPS在Nexus Repository Manager 3.0上搭建私有Docker仓库

    FROM: https://www.hifreud.com/2018/06/06/03-nexus-docker-repository-with-ssl/ 搭建方式 搭建SSL的Nexus官方提供两种 ...

  5. [转]Ubuntu18.04下使用Docker Registry快速搭建私有镜像仓库

    本文转自:https://blog.csdn.net/BigData_Mining/article/details/88233015 1.背景 在 Docker 中,当我们执行 docker pull ...

  6. Android业务组件化之Gradle和Sonatype Nexus搭建私有maven仓库

    前言: 公司的业务组件化推进的已经差不多三四个月的时间了,各个业务组件之间的解耦工作已经基本完成,各个业务组件以module的形式存在项目中,然后项目依赖本地的module,多少有点不太利于项目的并行 ...

  7. Maven私服搭建(Nexus Repository Manager 3)

    下载和安装 下载地址:https://help.sonatype.com/repomanager3/download 注意:Nexus Repository Manager 3是一个Java服务器应用 ...

  8. Nexus Repository Manager OSS 3.x 安装配置

    前言想要使用maven搭建项目,但是国内的网络环境可以想象,还有公司自己开发的jar包等问题,所以需要搭建一个maven的私服,这样便于管理. 找了一些教程,顺便记下来,当做笔记. 本文以Window ...

  9. Nexus Repository Manager 3(CVE-2019-7238) 远程代码执行漏洞分析和复现

    0x00 漏洞背景 Nexus Repository Manager 3是一款软件仓库,可以用来存储和分发Maven,NuGET等软件源仓库.其3.14.0及之前版本中,存在一处基于OrientDB自 ...

随机推荐

  1. System.Runtime.InteropServices.COMException 检索COM类工厂中CLSID{xxxxxxxxx}的组件时失败解决方法

    iis7.5中设定应用程序池中<进程模型>中<标识>为localSystem 提示:System.Runtime.InteropServices.COMException: 命 ...

  2. iOS - 切换rootViewController时,销毁之前的控制器

    一.iOS在切换根控制器时,如何销毁之前的控制器?(切换rootViewController时注意的内存泄漏) 首先.在iOS的ARC机制下,任何对象,当没有其他对象对他进行强引用时,都会被自动释放. ...

  3. LeetCode - 774. Minimize Max Distance to Gas Station

    On a horizontal number line, we have gas stations at positions stations[0], stations[1], ..., statio ...

  4. css3整理--media

    media语法: <link rel="stylesheet" media="screen and (max-width: 600px)" href=&q ...

  5. (ecj)Eclipse的Java编译器分析之一——ecj介绍

    Java是一个开放的平台,对于除发布编译器/解释器/基础类库之外,该语言的负责机构更多的是制定一系列标准,任何符合标准的厂商产品均可用于市场投放.甚至包括其编译器及解释器. (比如Hibernate提 ...

  6. windows 开启热点的命令行工具

    hotspot.bat @echo off @echo. setlocal enabledelayedexpansion if "%1" == "set" ( ...

  7. 【Linux】解决Android Stadio报错:error in opening zip file

    报错: Failed to complete Gradle Execution Cause: error in opening zip file. 原因: 安装gradle失败引起的,往往是上网需要验 ...

  8. API(二)之Requests and Responses

    这一部分可以让返回的api信息以两种格式呈现:.json和.api REST框架的核心部分.我们来介绍几个基本的组成部分. Request objects REST框架引入了Request对象来扩展常 ...

  9. PL-SVO

    pl-svo对第一帧提取点和线段特征,点特征直接保存为Point2f就行,对于线段特征保存线段的两个端点 void detectFeatures( FramePtr frame, vector< ...

  10. sql语句 isnull(列名,'')='' /STUFF的意思

    (1) SELECT  SYXH,ZYHM,YEXH,ISNULL(YETZ,'') AS YETZ ,RYKSMC,RYBQMC,HZXM FROM YG_BRSYK 如果列名数据等于NULL,那么 ...