docker私服搭建有官方的registry镜像,也有改版后的NexusOss3.x,因为maven的原因搭建了nexus,所以一并将docker私服也搭建到nexus上。

nexus的安装过程就单独说了,如果是2.x系列需要升级到2.14版本再升级到3.y系列,如果3.x到3.y直接升级就可以。

从3.0版本开始,nexus不再只是一个maven仓库,还可以是docker、npm、bower的私有仓库。

配置SSL

docker的仓库链接是基于HTTPS的,故一般情况下需要将nexus的访问方式改为支持https。

配置SSL主要的难点在于证书,证书可以用公网证书,而一般情况下,私服部署在内网,没有域名,用内网IP访问,这种情况下用自签名的证书是最好的选择。证书生成工具用jdk自带的就可以。

配置过程,进入${nexus}/etc/ssl目录下面,执行命令过程中会输入多次密码,记下密码,后面有用处:

  1. $ keytool -genkeypair -keystore example.jks -storepass password -alias example.com \
  2. > -keyalg RSA -keysize 2048 -validity 5000 -keypass password \
  3. > -dname 'CN=*.example.com, OU=Sonatype, O=Sonatype, L=Unspecified, ST=Unspecified, C=US' \
  4. > -ext 'SAN=DNS:nexus.example.com,DNS:clm.example.com,DNS:repo.example.com,DNS:www.example.com'
  5. Warning:
  6. The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore example.jks -destkeystore example.jks -deststoretype pkcs12".
  7. $ keytool -exportcert -keystore example.jks -alias example.com -rfc > example.cert
  8. Enter keystore password: password
  9. Warning:
  10. The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore example.jks -destkeystore example.jks -deststoretype pkcs12".
  11. $ keytool -importkeystore -srckeystore example.jks -destkeystore example.p12 -deststoretype PKCS12
  12. Importing keystore example.jks to example.p12...
  13. Enter destination keystore password:
  14. Re-enter new password:
  15. Enter source keystore password:
  16. Entry for alias example.com successfully imported.
  17. Import command completed: 1 entries successfully imported, 0 entries failed or cancelled
  18. $ openssl pkcs12 -nocerts -nodes -in example.p12 -out example.key
  19. Enter Import Password:
  20. MAC verified OK

修改配置文件:etc/nexus.properties

  1. 原:
  2. nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
  3. 修改后:
  4. application-port-ssl=8433
  5. nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-https.xml,${jetty.etc}/jetty-requestlog.xml

修改配置文件:etc/jetty/jetty-https.xml

  1. <New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
  2. <Set name="KeyStorePath"><Property name="ssl.etc"/>/keystore.jks</Set> // 文件名和前面证书的一致
  3. <Set name="KeyStorePassword">password</Set> // 密码用前面的
  4. <Set name="KeyManagerPassword">password</Set>
  5. <Set name="TrustStorePath"><Property name="ssl.etc"/>/keystore.jks</Set>
  6. <Set name="TrustStorePassword">password</Set>
  7. <Set name="EndpointIdentificationAlgorithm"></Set>
  8. <Set name="NeedClientAuth"><Property name="jetty.ssl.needClientAuth" default="false"/></Set>
  9. <Set name="WantClientAuth"><Property name="jetty.ssl.wantClientAuth" default="false"/></Set>
  10. <Set name="ExcludeCipherSuites">
  11. <Array type="String">
  12. <Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
  13. <Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item>
  14. <Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item>
  15. <Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item>
  16. <Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
  17. <Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
  18. <Item>SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA</Item>
  19. </Array>
  20. </Set>
  21. </New>

重启nexus,打开浏览器访问,https://ip:8443/ 会提示出来证书签名有问题,直接略过就行。

创建仓库(私有,代理,组合)

创建三个仓库,如果需要代理多个来源,可以创建多个代理库。

私有仓库:注意将http或者https的端口打开。

代理中央库的注意地址:

remote: https://registry-1.docker.io

docer index : use Docker hub

组合仓库将刚建立的Hosted和Proxy仓库都加入就可以了。

配置docker本地

本地配置最主要的是配置insecure-registries和docker login。

配置daemon.json

/etc/docker/daemon.json

  1. {
  2. "registry-mirrors": ["https://IP:18443"],
  3. "insecure-registries":["IP:18443","IP:18444"]
  4. }

为什么需要两个insecure-registry呢?因为group仓库不可以作为push仓库,如果单纯的进行pull,可以只配置一个。

docker login

分别login两个insecure-registry。

  1. $ docker login IP:18444
  2. Username (admin): admin
  3. Password:
  4. Login Succeeded
  5. $ docker login IP:18443
  6. Username (admin): admin
  7. Password:
  8. Login Succeeded

这样可以愉快的进行push和pull操作了。

push和pull的坑

nexus有一个设定,push只能对Hosted,pull从三种仓库都可以。因为push的操作给proxy的,是无法推送给被代理库的。group的仓库接受push后,无法确定是给proxy还是hosted。

但是nexus可以通过push给hosted的仓库,但是通过group仓库pull。

  1. $ docker images
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. alpine latest 3fd9065eaf02 5 months ago 4.15MB
  4. IP:18443/alpine latest 3fd9065eaf02 5 months ago 4.15MB
  5. $ docker tag alpine IP:18444/alpine
  6. $ docker push IP:18444/alpine
  7. The push refers to repository [IP:18444/alpine]
  8. cd7100a72410: Layer already exists
  9. latest: digest: sha256:8c03bb07a531c53ad7d0f6e7041b64d81f99c6e493cb39abba56d956b40eacbc size: 528
  10. $ docker images
  11. REPOSITORY TAG IMAGE ID CREATED SIZE
  12. alpine latest 3fd9065eaf02 5 months ago 4.15MB
  13. IP:18444/alpine latest 3fd9065eaf02 5 months ago 4.15MB
  14. $ docker pull IP:18443/alpine
  15. Using default tag: latest
  16. latest: Pulling from alpine
  17. Digest: sha256:8c03bb07a531c53ad7d0f6e7041b64d81f99c6e493cb39abba56d956b40eacbc
  18. Status: Image is up to date for IP:18443/alpine:latest
  19. $ docker images
  20. REPOSITORY TAG IMAGE ID CREATED SIZE
  21. alpine latest 3fd9065eaf02 5 months ago 4.15MB
  22. IP:18443/alpine latest 3fd9065eaf02 5 months ago 4.15MB
  23. IP:18444/alpine latest 3fd9065eaf02 5 months ago 4.15MB

完成。

docker私服搭建nexus3的更多相关文章

  1. Docker私服搭建--Harbor

    Docker私服搭建--Harbor Harbor概述 Harbor的安全机制 Harbor的镜像同步 Harbor的镜像同步机制 Harbor的多级部署 一.安装 1.1 docker安装 1.2 ...

  2. docker 快速搭建Nexus3

    1.拉取镜像 docker pull sonatype/nexus3 2.启动容器 : -p : -p : -v /mnt/gv0/nexus-data:/nexus-data sonatype/ne ...

  3. Docker Compose部署Nexus3时的docker-compose,yml代码

    场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...

  4. Docker 私服

    目录 什么是 Docker 私服? Docker 私服搭建 上传镜像至私服 从私服拉取镜像 什么是 Docker 私服? Docker 官方的 Docker Hub 是一个用于管理公共镜像的仓库,我们 ...

  5. Docker 搭建 Nexus3 私服 | 基本操作

    1 Docker 安装 Nexus3 1.1 创建目录 在硬盘上创建 Nexus3 的主目录: mkdir -p /Users/yygnb/dockerMe/nexus3 为该目录添加权限: chmo ...

  6. 搭建Nexus3私服(含使用说明,支持CentOS、Windows)

    官方文档 Nexus仓库介绍(支持maven.yum.docker私服等) 仓库分为三种: proxy:是远程仓库的代理.比如说在nexus中配置了一个central repository的proxy ...

  7. 使用nexus搭建一个docker私服

    使用nexus搭建docker私服 一.需求: 二.实现步骤 1.编写`docker-compose`文件,实现`nexus`的部署 2.修改/usr/lib/systemd/system/docke ...

  8. 【Maven】---Linux搭建Nexus3.X私服

    Linux搭建Nexus3.X私服 备注:linux版本: ubuntu 同时已经部署好JDK8环境 一.linux安装nexus 1.创建文件夹并进入该目录 cd /usr/local && ...

  9. 使用registry搭建docker私服仓库

    使用registry搭建docker私服仓库 一.拉取 registry镜像 二.根据镜像启动一个容器 1.创建一个数据卷 2.启动容器 三.随机访问一个私服的接口,看是否可以返回数据 四.推送一个镜 ...

随机推荐

  1. 按要求分解字符串,输入两个数M,N;M代表输入的M串字符串,N代表输出的每串字符串的位数,不够补0。例如:输入2,8, “abc” ,“123456789”,则输出为“abc00000”,“12345678“,”90000000”

    import java.util.ArrayList; import java.util.Scanner; public class Text { @SuppressWarnings("re ...

  2. python第二课——数据类型1

    day02(上午)主要讲了进制问题,小编之前已经发过了 day02(下午): 1.数据类型: 分类: 1).整数型:int浮点型(小数):float布尔型(True/False):bool 2).字符 ...

  3. redis key/value 出现\xAC\xED\x00\x05t\x00\x05

    1.问题现象: 最近使用spring-data-redis 和jedis 操作redis时发现存储在redis中的key不是程序中设置的string值,前面还多出了许多类似\xac\xed\x00\x ...

  4. github与git基本操作(一)

    一.git上传本地项目到github 前提:github创建一个空仓库(得到“https://自己的仓库url地址”)1.第一步:就是要进入这个目录下,cmd2.第二步:输入git init3.第三步 ...

  5. Python+django+uWSGI+Nginx

    Python3.5+Django+uWSGI 安装Django pip3.5 install django 安装 uWSGI pip install uwsgi 新建 django_wsgi.py # ...

  6. JDBC数据对象存储

    一:将查询的结果生成对象,储存在数组中. package day31; import java.sql.Connection; import java.sql.PreparedStatement; i ...

  7. .net 读取Excel 数据时出现 “外部表不是预期的格式”的解决办法

    参考网上的资料有以下2种情况: 第一:excel本身的格式不正确,用记事本打开文件,如果显示乱码证明文件没有问题,如果是html那就证明文件格式不正确. 第二:由excel版本版本导致,例如:2003 ...

  8. 在windows上安装不同(两个)版本的Mysql数据库

    1.起因: 需要导入一个sql文件,发现死活导不进去.当执行到这一句时,就有问题.经过一番搜索,原来是我的数据库版本(原先Mysql版本5.5)低了,而支持该语句的版本应该是至少要5.7.那我索性就去 ...

  9. 飞控入门之C语言指针回顾

    指针 何为指针?来个官方定义:指针是一个值为内存地址的变量(或数据对象). 一.指针的声明 //示例 int *pi; //pi是指向int类型变量的指针 char *pc; // pi是指向char ...

  10. angular自定义过滤器在页面和控制器中的使用

    首先设置自定义过滤器. 定义模块名:angular .module('myApp') .filter('filterName',function(){ return function(要过滤的对象,参 ...