Nexus3能够支持Maven、Docker、NuGet、npm、Bower等,做为一个稳定的私服产品经常用于咱们开发管理过程当中。java
用Nexus搭建本地私服有以下好处:docker
这些优势使得Nexus日益成为主流的仓库管理器之一npm
闲话少叙,上图json
Nexus3.x 相较 2.x 版本有很大的改变centos
1.下载Nexus3的镜像浏览器
访问hub.docker.com/,搜索nexus以下图bash
选择第一个,官方原装进口版本,执行以下命令,我这里已经下载好了服务器
root@surging:~# docker pull sonatype/nexus3
Using default tag: latest
latest: Pulling from sonatype/nexus3
Digest: sha256:3262783b5f44c6265cf867b390e84a643b855873b2018c0d28037d7cd29a89cf
Status: Image is up to date for sonatype/nexus3:latest
docker.io/sonatype/nexus3:latest
复制代码
2.使用镜像启动一个容器less
$ docker run -d -p 8081:8081 -p 8082:8082 -p 8083:8083 --name nexus3 -v /home/nexus/nexus-data:/nexus-data --restart=always sonatype/nexus3复制代码
注意 --restart=always:
加上这个指令无论退出状态码是什么始终重启容器。当指定always时,docker daemon将无限次数地重启容器。容器也会在daemon启动时尝试重启,无论容器当时的状态如何。elasticsearch
启动以后咱们就能够经过http://服务器IP:8081访问,相关界面以下图
nexus3默认的帐号依旧是admin可是密码已经变了具体的密码存储在nexus3的容器的nexus-data路径内的admin.password文件内
具体操做:
a. 查看nexus3容器id,执行 docker ps
控制台显示
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2bc9db68ba83 elasticsearch:5.6.16 "/docker-entrypoint.…" 2 weeks ago Up 2 weeks 0.0.0.0:19200->9200/tcp, 0.0.0.0:19300->9300/tcp es5
01b398d530aa sonatype/nexus3 "sh -c ${SONATYPE_DI…" 2 weeks ago Up 2 weeks 0.0.0.0:8081-8083->8081-8083/tcp nexus3
e3a1b31ed4f4 registry:2 "/entrypoint.sh /etc…" 5 months ago Up 2 weeks 0.0.0.0:5000->5000/tcp registryb复制代码
b. 进入容器控制台执行 docker exec -it 01b398d530aa bash
控制台显示
docker exec -it 01b398d530aa bash
bash-4.4$ ls
bin boot dev etc help.1 home lib lib64 licenses lost+found media mnt nexus-data opt proc root run sbin srv sys tmp uid_entrypoint.sh uid_template.sh usr var
bash-4.4$ cd nexus-data/
bash-4.4$ ls
admin.password db generated-bundles karaf.pid log restore-from-backup
blobs elasticsearch instances keystores orient tmp
cache etc javaprefs lock portad复制代码
admin.password中的第一行就是密码,复制密码使用admin登陆,登陆成功以后系统会自动提示你更换admin密码
http://服务器IP:8081
点击右上角进行登陆,密码就是你刚才设置的密码:
点击设置界面,选择Repositories,点击Create repository,以下图所示:
这里Docker有三种类型,分别是group、hosted、proxy。选择docker(hosted),以下图:
注:Docker镜像仓库类型含义解释以下:
指定docker仓库的名称、指定一个端口用来经过http的方式进行访问仓库、勾选是否支持docker API V1,而后create repository;
我本地已经登陆过仓库了,直接显示成功,账号密码可使用admin,也能够在nexus中自行配置,这里就不赘述了
docker login 10.10.1.10:8082
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded复制代码