准备工作

Docker安装

安装

下载镜像

 运行镜像

执行以上命令后镜像没有启动成功,使用如下命令看启动日志:

我在启动时遇到的问题:

处理方案:

以下是对启动命令的解释:

  1. 端口映射
  • 8082端口是用于host镜像仓库的服务端口
  • 8083端口用户group镜像仓库的服务端口
  • 8081 端口是nexus的服务端口

2. 进程名

  • --name nexus3

3. 持久化

/home/root/data/nexus/data:/nexus-data 将容器内nexus-data数据文件夹挂载到宿主机/home/root/data/nexus/data目录下
4. 指定要运行的镜像名

docker images可以查看所有镜像名

sonatype/nexus3是要运行的镜像名,如果后面不加版本号,则默认启动latest版本
5. 跟随docker启动 

--restart=always:
意思是不管退出状态码是什么始终重启容器。当指定always时,docker daemon将无限次数地重启容器。容器也会在daemon启动时尝试重启,不管容器当时的状态如何。

  • no :容器退出时不要自动重启。这个是默认值。
  • on-failure[:max-retries] : 只在容器以非0状态码退出时重启。可选的,可以退出docker daemon尝试重启容器的次数。
  • always :不管退出状态码是什么始终重启容器。当指定always时,docker daemon将无限次数地重启容器。容器也会在daemon启动时尝试重启,不管容器当时的状态如何。
  • unless-stopped :不管退出状态码是什么始终重启容器,不过当daemon启动时,如果容器之前已经为停止状态,不要尝试启动它

访问

http://192.168.10.122:8081

输入账号/密码,nexus3密码不是默认的admin/admin123,而是在/nexus-data/admin.password文件中,使用如下方法获取

进去之后默认会提示修改密码,然后会弹出一个安全配置,选择第一个选项,这样其他人可以不需要认证也可以搜索和访问maven仓库,比如拉取jar包

设置

设置代理到阿里云的仓库

Docker安装Nexus3-LMLPHP

Docker安装Nexus3-LMLPHP

地址:https://maven.aliyun.com/repository/public

创建用户

Docker安装Nexus3-LMLPHP

Setting.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>F:\data\maven\repository</localRepository>
    <mirrors>
		<mirror>
			<id>nexus</id>
			<mirrorOf>*</mirrorOf>
			<name>nexus epzoon</name>
			<url>http://39.181.173.180:8081/repository/maven-public/</url>
		</mirror>
    </mirrors>
	<server>
		<id>test</id>
        <username>test</username>
        <password>test!123</password>
	</server>
	<profiles>
        <profile>
            <id>nexus</id>
            <repositories>
                <!-- 私有库地址-->
                <repository>
                    <id>nexus</id>
                    <url>http://39.181.173.180:8081/repository/maven-public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <!--插件库地址-->
                <pluginRepository>
                    <id>nexus</id>
                    <url>http://39.181.173.180:8081/repository/maven-public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>
09-01 21:54