nexus3 docker 本地镜像搭建

本文介绍如何为Nexus仓库管理器配置HTTPS,并详细说明了生成自签名证书的过程,以及如何修改Nexus配置文件以启用HTTPS。此外,还介绍了如何确保Docker客户端能够信任Nexus的自签名证书。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境及软件版本

OS

CentOS Linux release 7.4.1708 (Core)

nexus

OSS 3.6.0-02

docker --version
Docker version 1.12.6, build 85d7426/1.12.6


第一步 nexus 开启https 

-因 docker默认使用 https链接,虽然有配置用http 但是推荐用https 还有是设置参数没成功

nexus 开启 https访问

1自签证书生成

cd /home/nexus/soft/nexus-3.6.0-02/etc/ssl

keytool -genkeypair -keystore keystore.jks -storepass changeit -keypass changeit -alias jetty -keyalg RSA -keysize 2048 -validity 5000 -dname "CN=*.nexus, OU=Example, O=Sonatype, L=Unspecified, ST=Unspecified, C=US" -ext "SAN=DNS:nexus,IP:192.168.xx.xx" -ext "BC=ca:true"

2 修改nexus 配置

2.1 /home/nexus/soft/sonatype-work/nexus3/etc/nexus.properties

参考

# Jetty section

# application-port=8081

# application-host=0.0.0.0

# nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml

# nexus-context-path=/

secureScheme=https

securePort=9443

application-port-ssl=9443

application-host=192.168.xx.xx

nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml,${jetty.etc}/jetty-https.xml

# Nexus section

# nexus-edition=nexus-pro-edition

# nexus-features=\

#  nexus-pro-feature

2.2 修改 jetty-https.xml

/home/nexus/soft/nexus-3.6.0-02/etc/jetty/jetty-https.xml

参考修改片段

 <New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">

  <!--

    <Set name="KeyStorePath"><Property name="ssl.etc"/>/home/nexus/soft/nexus-3.6.0-02/etc/ssl/keystore.jks</Set>

    <Set name="KeyStorePassword">nexus3</Set>

    <Set name="KeyManagerPassword">nexus3</Set>

    <Set name="TrustStorePath"><Property name="ssl.etc"/>/home/nexus/soft/nexus-3.6.0-02/etc/ssl/keystore.jks</Set>

    <Set name="TrustStorePassword">nexus3</Set>

-->

<Set name="KeyStorePath"><Property name="ssl.etc"/>/keystore.jks</Set>

    <Set name="KeyStorePassword">changeit</Set>

    <Set name="KeyManagerPassword">changeit</Set>

    <Set name="TrustStorePassword">changeit</Set>

    <Set name="EndpointIdentificationAlgorithm"></Set>

    <Set name="NeedClientAuth"><Property name="jetty.ssl.needClientAuth" default="false"/></Set>

    <Set name="WantClientAuth"><Property name="jetty.ssl.wantClientAuth" default="false"/></Set>

    <Set name="ExcludeCipherSuites">

2.3 重启nexus 

访问 https:IP:port

/home/nexus/soft/nexus-3.6.0-02/bin/nexus stop

/home/nexus/soft/nexus-3.6.0-02/bin/nexus start


2.4 新建docker 库

参考图片配置




到此 nexus 配置设置完成


第二步 docker 环境配置

必须把自签证书加入到docker环境受信任不然会报如下错

          Error response from daemon: Get https://192.168.xx.xx:9445/v1/users/: x509: certificate signed by unknown authority

导出证书

   cd xxx/xx/store/

keytool -printcert -sslserver 192.168.xx.xx:9445 -rfc >nexus.crt

cp nexus.crt /etc/pki/ca-trust/source/anchors/

update-ca-trust extract

更改host

vi /etc/hosts

192.168.xx.xx  nexus


重启docker demon

service docker stop

service docker start


第三步 登录 - 忽略了nexus 新建账号步骤 假设你账号已经建立

docker login -u user -p password nexus:9445

or

# docker login  nexus:9445

Username: admin

Password:

Login Succeeded



参考:

https://support.sonatype.com/hc/en-us/articles/217542177-Using-Self-Signed-Certificates-with-Nexus-Repository-Manager-and-Docker-Daemon

https://help.sonatype.com/display/NXRM3/Configuring+SSL






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值