docker部署nexus并啟用https方式
docker部署nexus并啟用https
實(shí)現(xiàn)目標(biāo)
- docker 運(yùn)行nexus
- nexus docker倉(cāng)庫(kù)支持https
- docker client只需要把ca證書(shū)放到docker目錄下,不需要整個(gè)機(jī)器信任。
- nexus用 ip:port的方式訪問(wèn)
構(gòu)建nexus鏡像
生成證書(shū)
# 這里的ip換為nexus運(yùn)行機(jī)器的ip
echo subjectAltName = IP:10.110.25.191 > extfile.cnf
# 生成ca
openssl genrsa -out ca.key 2048
openssl req -x509 -new -nodes -key ca.key -days 5000 -out ca.crt
# 生成server證書(shū)
openssl genrsa -out server.key 2048
openssl req -new -key server.key -subj "/CN=10.110.25.191" -out server.csr
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -extfile extfile.cnf -out server.crt -days 5000
# 將證書(shū)導(dǎo)出成pkcs格式
# 這里需要輸入密碼 用password,如果不用這個(gè),需要修改鏡像里的${jetty.etc}/jetty-https.xml,具體操作參考百度。
openssl pkcs12 -export -out keystore.pkcs12 -inkey server.key -in server.crt構(gòu)建鏡像
FROM sonatype/nexus3
USER root
COPY keystore.pkcs12 /keystore.pkcs12
RUN keytool -v -importkeystore -srckeystore keystore.pkcs12 -srcstoretype PKCS12 -destkeystore keystore.jks -deststoretype JKS -storepass password -srcstorepass password &&\
cp keystore.jks /opt/sonatype/nexus/etc/ssl/
USER nexusdocker build ./ -t nexus-https
啟動(dòng)
# 8443是nexus ui https訪問(wèn)端口
# 8081是nexus ui http訪問(wèn)端口
# 8082將要用來(lái)作為docker代理docker hub的端口
# 8083將要用來(lái)作為docker本地倉(cāng)庫(kù)的端口
docker run -d --restart=always -p 8443:8443 -p 8081:8081 -p 8082:8082 -p 8083:8083 --name nexus3 -v /docker/nexus/nexus-data:/nexus-data nexus-https:latest
# 修改nexus的目錄權(quán)限
chmod -R 777 /docker
# 等容器啟動(dòng),可以正常訪問(wèn)頁(yè)面之后修改配置文件,開(kāi)啟ssl
vim /docker/nexus/nexus-data/etc/nexus.properties
# 內(nèi)容如下:
# Jetty section
application-port-ssl=8443
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,${jetty.etc}/jetty-https.xml
nexus-context-path=/${NEXUS_CONTEXT}
#Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
nexus-pro-feature
nexus.clustered=false
# 重啟容器
docker restart nexus3創(chuàng)建倉(cāng)庫(kù)
設(shè)置realms
在realms中把 docker bearer token realm 選為 active
創(chuàng)建docker的代理倉(cāng)庫(kù),代理docker hub
設(shè)置 -> repositories -> create repositories -> docker(proxy)
把https的選項(xiàng)選上,端口號(hào)填寫(xiě)8082,Docker index 選擇Docker Hub,其他的按照默認(rèn)填寫(xiě)
client訪問(wèn)
在client端的服務(wù)器上創(chuàng)建 /etc/docker/certs.d/<nexus ip>:8082/文件夾。
將生成ca證書(shū)步驟生成的 ca.crt復(fù)制到 這個(gè)文件夾中。
docker login 試一下。
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
docker私有倉(cāng)庫(kù)harbor搭建過(guò)程
這篇文章主要介紹了docker私有倉(cāng)庫(kù)harbor搭建過(guò)程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-06-06
docker實(shí)現(xiàn)buildx構(gòu)建多平臺(tái)(x86,arm64)構(gòu)架鏡像
這篇文章主要介紹了docker實(shí)現(xiàn)buildx構(gòu)建多平臺(tái)(x86,arm64)構(gòu)架鏡像,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2025-09-09
Docker安裝kafka并創(chuàng)建topic進(jìn)行消息通信過(guò)程
本文介紹了如何使用Docker容器化技術(shù)來(lái)安裝和配置Apache?Kafka,并詳細(xì)介紹了如何創(chuàng)建topic進(jìn)行消息通信,通過(guò)Docker和Docker?Compose兩種方式,可以方便地搭建Kafka集群,并進(jìn)行消息的發(fā)布和訂閱2025-12-12
docker swarm如何在指定的node上運(yùn)行指定的容器
這篇文章主要介紹了docker swarm如何在指定的node上運(yùn)行指定的容器,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-07-07
Docker實(shí)現(xiàn)容器化的分布式鎖服務(wù)RedisLock的快速搭建
本文主要介紹了Docker實(shí)現(xiàn)容器化的分布式鎖服務(wù)RedisLock的快速搭建,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2026-04-04
docker?build?和compose?學(xué)習(xí)筆記
Docker?build構(gòu)建鏡像,docker-compose?up?-d啟動(dòng)多容器應(yīng)用,前者需Dockerfile,后者需docker-compose.yml,Compose可自動(dòng)調(diào)用Build或使用現(xiàn)有鏡像,協(xié)同提升開(kāi)發(fā)效率與環(huán)境一致性,本文給大家分享docker?build?和compose?學(xué)習(xí)筆記,感興趣的朋友一起看看吧2025-07-07
Docker部署postgresql的方法實(shí)現(xiàn)
本文主要介紹了Docker部署postgresql的方法實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2025-01-01
windows宿主機(jī)和docker容器設(shè)置掛載共享文件夾的步驟
這篇文章主要介紹了windows宿主機(jī)和docker容器設(shè)置掛載共享文件夾的步驟,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-11-11

