Docker搭建Maven私服和Gitlab

目录

一、安装Maven私服Sonatype Nexus

二、安装Gitlab


一、安装Maven私服Sonatype Nexus

1、下载镜像

[root@localhost ~]# docker pull sonatype/nexus3

2、挂载启动

[root@localhost ~]#  docker run -d -p 8081:8081 --name nexus -v /root/nexus-data:/var/nexus-data --restart=always sonatype/nexus3

3、关闭防火墙  

[root@localhost ~]# systemctl stop firewalld

4、浏览器访问http//ip:8081/

5、查看密码

admin:[root@localhost ~]# docker exec -it 0a3be49d95a0 bash

bash-4.4$ cat /nexus-data/admin.password

400aa478-eb9c-454f-92f8-11b0e3534389bash-4.4$ #bash前面的部分为密码

6、配置(settings.xml)

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!--本地仓库-->
<localRepository>D:\maven\my_repository</localRepository>	

<!--添加账号-->
	<servers>
		<server>
    <!--此处id需要对应项目中pom.xml文件中的<distributionManagement> 标签下的id-->
      <id>test-release</id> 
      <username>admin</username>
      <password>123456</password>
    </server>
    <server>
      <id>test-snapshots</id>
      <username>admin</username>
      <password>123456</password>
    </server>
	</servers>
	<profiles>
		<profile>   
		<!--profile的id-->
		<id>dev</id>   
		<repositories>   
		  <repository>  
			<!--仓库id,repositories可以配置多个仓库,保证id不重复-->
			<id>nexus</id>   
			<!--仓库地址,即nexus仓库组的地址-->
			<url>http://192.168.6.135:8081/repository/maven-public/</url>   
			<!--是否下载releases构件-->
			<releases>   
			  <enabled>true</enabled>   
			</releases>   
			<!--是否下载snapshots构件-->
			<snapshots>   
			  <enabled>true</enabled>   
			</snapshots>   
		  </repository>   
		</repositories>  
		 <pluginRepositories>  
			<!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
			<pluginRepository>  
				<!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
				<id>public</id>  
				<name>Public Repositories</name>  
				<url>http://192.168.6.135:8081/repository/maven-public/</url>  
			</pluginRepository>  
		</pluginRepositories>  
  </profile>	
	</profiles>
	
	<activeProfiles>
		<activeProfile>dev</activeProfile>
	</activeProfiles>
		
	<!--<mirrors>
		<mirror>
        <id>alimaven</id>
        <mirrorOf>*</mirrorOf>
        <name>aliyun maven</name>
        <url>https://maven.aliyun.com/repository/public</url>
     </mirror>	
	</mirrors>-->
</settings>

pom文件

    <distributionManagement>
        <repository>
            <id>test-release</id>
            <url>http://192.168.6.135:8081/repository/test-release/</url>
        </repository>
        <snapshotRepository>
            <id>test-snapshots</id>
            <url>http://192.168.6.135:8081/repository/test-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

二、安装Gitlab

1、拉取镜像

[root@localhost ~]# docker pull beginor/gitlab-ce

2、创建日记数据等文件

[root@localhost ~]# mkdir -p /mnt/gitlab/etc
[root@localhost ~]# mkdir -p /mnt/gitlab/log
[root@localhost ~]# mkdir -p /mnt/gitlab/data

3、运行容器

docker run \
    --detach \
    --publish 8443:443 \
    --publish 8090:8090 \
    --name gitlab \
    --restart unless-stopped \
    -v /mnt/gitlab/etc:/etc/gitlab \
    -v /mnt/gitlab/log:/var/log/gitlab \
    -v /mnt/gitlab/data:/var/opt/gitlab \
    beginor/gitlab-ce:latest

4、修改配置

[root@localhost ~]# vi /mnt/gitlab/etc/gitlab.rb
#修改这句,这个地址就是我们clone时那个地址 external_url 'http://192.168.6.135:8090'

 

[root@localhost ~]# vi /mnt/gitlab/data/gitlab-rails/etc/gitlab.yml

 5、重新启动容器

#查看运行的镜像
[root@localhost ~]# docker ps
#重启docker
[root@localhost ~]# systemctl restart docker
#重启容器
[root@localhost ~]# docker restart gitlab

6、访问http://ip:8090

注意:设置密码时候,密码长度不能小于8位

参考:

https://blog.csdn.net/sinat_39789638/article/details/77918292
https://blog.csdn.net/yanglinna/article/details/104293436/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

熟透的蜗牛

永远满怀热爱,永远热泪盈眶

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值