美文网首页Maven随笔-生活工作点滴
【nexus】更改nexus镜像中用户的默认uid

【nexus】更改nexus镜像中用户的默认uid

作者: Bogon | 来源:发表于2019-07-07 08:00 被阅读6次

一、实验背景

实际的跟docker相关微服务项目中,出于安全考虑,我们可能会要求各个服务用非root运行,统一服务运行用户,那么需要将第三方开源软件的默认用户id做更改。

nexus的默认用户是nexus,uid为200 ,如果项目中的统一用户uid为2019,我们怎么在官方Dockerfile的基础上将其改造呢?

不同版本,nexus的官方Dockerfile不一样,我们需要区别对待。

下面以nexus-3.5.2和nexus3.1.0为例,其他版本或者说其他软件的镜像处理方式大同小异,当然如果不想在官方Dockerfile的基础上操作,你可以自己重新打一个镜像!

Download Archives - Repository Manager 3

https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3

二、拉取官方Dockerfile修改默认uid

对nexus-3.5.2的处理

#  git clone  https://github.com/sonatype/docker-nexus3.git 

# cd docker-nexus3/

# git tag 

# git checkout 3.5.2

# vim Dockerfile 

如图位置 ,添加gid,更新uid 

# docker build -f Dockerfile -t sonatye/nexus3:3.5.2  .

# docker save -o  nexus3-3.5.2.tar     sonatye/nexus3:3.5.2  

对nexus-3.10.0的处理

#  git clone   https://github.com/sonatype/docker-nexus3.git 

# cd docker-nexus3/

# git tag 

# git checkout 3.10.0

# vim Dockerfile 

如图位置 ,添加如下代码,修改nexus用户的默认uid

##########################################################

# Modify default nexus uid

RUN sed -i '/^nexus/s/200/2019/g' /etc/passwd \

    && chown -R nexus:nexus /nexus-data/ \

    && chown nexus:nexus /opt/sonatype/nexus \

    && chown nexus:nexus /opt/sonatype/nexus/etc \

    && chown nexus:nexus /opt/sonatype/nexus/etc/nexus-default.properties

##############################################################

# docker build -f Dockerfile -t sonatye/nexus3:10.0 .

# docker save -o  nexus3-3.10.0.tar     sonatye/nexus3:10.0 

三、参考

Download Archives - Repository Manager 3

https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3

nexus-https

https://github.com/bradbeck/nexus-https

sonatype/docker-nexus3

https://github.com/sonatype/docker-nexus3

相关文章

网友评论

    本文标题:【nexus】更改nexus镜像中用户的默认uid

    本文链接:https://www.haomeiwen.com/subject/kcgvhctx.html