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

一、实验背景

实际的跟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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容