Maven私服:Docker安装nexus3
Maven私服:Docker安装nexus3
查找nexus3镜像
develop@ubuntu:~$ docker search nexus3
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
sonatype/nexus3 Sonatype Nexus Repository Manager 3 697
shifudao/nexus3 clone from nexus3 image but based from openj… 4 [OK]
madmuffin/nexus3 Sonatype Nexus3 Milestone7 docker image 2 [OK]
home1oss/nexus3 An auto configured nexus3 2 [OK]
fxinnovation/nexus3 Sonatype Nexus 3 in a container 1 [OK]
flavioaiello/nexus3 Production ready lightweight Nexus3 with API… 1 [OK]
cirepo/nexus3 An auto configured nexus3 1 [OK]
alvindaiyan/nexus3-azure-appservice 1
dwolla/nexus3-crowd Nexus3 with nexus3-crowd-plugin installed 0 [OK]
joshdvir/nexus3 nexus3 0 [OK]
freckleiot/nexus3-oss A Sonatype Nexus3 OSS image which makes it e… 0 [OK]
sdase/nexus3-base-image An opinionated nexus3 docker image, based on… 0 [OK]
fgbulsoni/nexus3 My fork of the Sonatype/Nexus3 image, with a… 0
stocksoftware/nexus3 A nexus3 docker instance 0 [OK]
azaa1/nexus3 Sonyatype Nexus Repository Manager 3 0
salte/nexus3 Extends the Sonatype nexus3 Docker image by … 0 [OK]
mritd/nexus3 nexus3 0 [OK]
desiato/nexus3-ssl Sonatype Nexus 3 with SSL/TLS support. 0 [OK]
lokkju/nexus3-github-auth Sonatype Nexus 3 with Github authentication … 0 [OK]
jullyannem/nexus3 Custom image for sonatype/nexus3 0
bigseasre/nexus3 mirror of the original nexus3 dockerfile 0
darthhater/nexus3 A series of example Dockerfiles and images f… 0 [OK]
amribrahim00/nexus3 0
enieuw/nexus3-oss nexus3-oss 0 [OK]
nasajon/nexus3 Nexus3 0 [OK]
拉取nexus3镜像
develop@ubuntu:~$ docker search sonatype/nexus3
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
develop@ubuntu:~$ docker image pull sonatype/nexus3
Using default tag: latest
latest: Pulling from sonatype/nexus3
c65691897a4d: Pull complete
641d7cc5cbc4: Pull complete
c508b13320cd: Pull complete
79e3bf9d3132: Pull complete
Digest: sha256:2c33632ccd8f8c5f9023a3d7f5f541e271833e402219f8c5a83a29d1721457ca
Status: Downloaded newer image for sonatype/nexus3:latest
docker.io/sonatype/nexus3:latest
查看镜像
develop@ubuntu:~$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat 8.5.47 882487b8be1d 12 days ago 507MB
ubuntu 16.04 b9409899fe86 12 days ago 122MB
ubuntu 18.04 cf0f3ca922e0 12 days ago 64.2MB
node 10.16.3 a68faf70e589 13 days ago 904MB
mysql 5.7.28 cd3ed0dfff7e 13 days ago 437MB
nginx 1.17.4 5a9061639d0a 13 days ago 126MB
redis 5.0.6 de25a81a5a0b 2 weeks ago 98.2MB
sonatype/nexus3 latest 8eb898be2a53 3 weeks ago 611MB
centos 8 0f3e07c0138f 4 weeks ago 220MB
busybox latest 19485c79a9bb 8 weeks ago 1.22MB
centos 7 67fa590cfc1c 2 months ago 202MB
centos 7.6.1810 f1cb7c7d58b7 7 months ago 202MB
centos 6 d0957ffdf8a2 7 months ago 194MB
查看docker nexus3 暴露端口
第一种方式 history
develop@ubuntu:~$ docker image history sonatype/nexus3:latest
IMAGE CREATED CREATED BY SIZE COMMENT
8eb898be2a53 3 weeks ago /bin/sh -c #(nop) CMD ["sh" "-c" "${SONATYP… 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ENV INSTALL4J_ADD_VM_PARA… 0B
<missing> 3 weeks ago /bin/sh -c #(nop) USER nexus 0B
<missing> 3 weeks ago /bin/sh -c #(nop) EXPOSE 8081 0B
<missing> 3 weeks ago /bin/sh -c #(nop) VOLUME [/nexus-data] 0B
<missing> 3 weeks ago |5 NEXUS_DOWNLOAD_SHA256_HASH=7a2e62848abeb0… 403MB
<missing> 3 weeks ago /bin/sh -c #(nop) ADD file:96a8726e4f3ee18b6… 1.97kB
<missing> 3 weeks ago /bin/sh -c #(nop) ARG NEXUS_REPOSITORY_MANA… 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ARG NEXUS_REPOSITORY_MANA… 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ENV NEXUS_HOME=/opt/sonat… 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ENV SONATYPE_DIR=/opt/son… 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ARG NEXUS_DOWNLOAD_SHA256… 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ARG NEXUS_DOWNLOAD_URL=ht… 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ARG NEXUS_VERSION=3.19.1-… 0B
<missing> 3 weeks ago /bin/sh -c #(nop) LABEL vendor=Sonatype mai… 0B
<missing> 6 weeks ago 3.55kB
<missing> 6 weeks ago 208MB Imported from -
第二种方式 inspect
develop@ubuntu:~$ docker image inspect sonatype/nexus3:latest
[
{
"Id": "sha256:8eb898be2a53434ed2310948ef1d4eb52d8298d400f0414d1fc5448cb10c1dc1",
"RepoTags": [
"sonatype/nexus3:latest"
],
"RepoDigests": [
"sonatype/nexus3@sha256:2c33632ccd8f8c5f9023a3d7f5f541e271833e402219f8c5a83a29d1721457ca"
],
"Parent": "",
"Comment": "",
"Created": "2019-10-09T16:17:15.370913182Z",
"Container": "e313220b483cfb870091d005efa119f8349d671b132191eff68523eb8a0412fe",
"ContainerConfig": {
"Hostname": "a3a96c4a2d45",
"Domainname": "",
"User": "nexus",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"8081/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"container=oci",
"SONATYPE_DIR=/opt/sonatype",
"NEXUS_HOME=/opt/sonatype/nexus",
"NEXUS_DATA=/nexus-data",
"NEXUS_CONTEXT=",
"SONATYPE_WORK=/opt/sonatype/sonatype-work",
"DOCKER_TYPE=rh-docker",
"INSTALL4J_ADD_VM_PARAMS=-Xms1200m -Xmx1200m -XX:MaxDirectMemorySize=2g -Djava.util.prefs.userRoot=/nexus-data/javaprefs"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"sh\" \"-c\" \"${SONATYPE_DIR}/start-nexus-repository-manager.sh\"]"
],
"ArgsEscaped": true,
"Image": "sha256:4394c38c7fba645a92c4f96d71f05c9dcee3cd2259e7a45e69a655cafd775db4",
"Volumes": {
"/nexus-data": {}
},
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": [],
"Labels": {
"architecture": "x86_64",
"authoritative-source-url": "registry.access.redhat.com",
"build-date": "2019-09-16T12:28:55.971236",
"com.redhat.build-host": "cpt-1001.osbs.prod.upshift.rdu2.redhat.com",
"com.redhat.component": "ubi8-container",
"com.redhat.license_terms": "https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI",
"com.sonatype.license": "Apache License, Version 2.0",
"com.sonatype.name": "Nexus Repository Manager base image",
"description": "The Universal Base Image is designed and engineered to be the base layer for all of your containerized applications, middleware and utilities. This base image is freely redistributable, but Red Hat only supports Red Hat technologies through subscriptions for Red Hat products. This image is maintained by Red Hat and updated regularly.",
"distribution-scope": "public",
"io.k8s.description": "The Universal Base Image is designed and engineered to be the base layer for all of your containerized applications, middleware and utilities. This base image is freely redistributable, but Red Hat only supports Red Hat technologies through subscriptions for Red Hat products. This image is maintained by Red Hat and updated regularly.",
"io.k8s.display-name": "Red Hat Universal Base Image 8",
"io.openshift.expose-services": "",
"io.openshift.tags": "base rhel8",
"maintainer": "Sonatype <cloud-ops@sonatype.com>",
"name": "ubi8",
"release": "208",
"summary": "Provides the latest release of Red Hat Universal Base Image 8.",
"url": "https://access.redhat.com/containers/#/registry.access.redhat.com/ubi8/images/8.0-208",
"vcs-ref": "592956edf47ff0ce45123f240898eabb469ac836",
"vcs-type": "git",
"vendor": "Sonatype",
"version": "8.0"
}
},
"DockerVersion": "18.09.6",
"Author": "",
"Config": {
"Hostname": "a3a96c4a2d45",
"Domainname": "",
"User": "nexus",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"8081/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"container=oci",
"SONATYPE_DIR=/opt/sonatype",
"NEXUS_HOME=/opt/sonatype/nexus",
"NEXUS_DATA=/nexus-data",
"NEXUS_CONTEXT=",
"SONATYPE_WORK=/opt/sonatype/sonatype-work",
"DOCKER_TYPE=rh-docker",
"INSTALL4J_ADD_VM_PARAMS=-Xms1200m -Xmx1200m -XX:MaxDirectMemorySize=2g -Djava.util.prefs.userRoot=/nexus-data/javaprefs"
],
"Cmd": [
"sh",
"-c",
"${SONATYPE_DIR}/start-nexus-repository-manager.sh"
],
"ArgsEscaped": true,
"Image": "sha256:4394c38c7fba645a92c4f96d71f05c9dcee3cd2259e7a45e69a655cafd775db4",
"Volumes": {
"/nexus-data": {}
},
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": [],
"Labels": {
"architecture": "x86_64",
"authoritative-source-url": "registry.access.redhat.com",
"build-date": "2019-09-16T12:28:55.971236",
"com.redhat.build-host": "cpt-1001.osbs.prod.upshift.rdu2.redhat.com",
"com.redhat.component": "ubi8-container",
"com.redhat.license_terms": "https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI",
"com.sonatype.license": "Apache License, Version 2.0",
"com.sonatype.name": "Nexus Repository Manager base image",
"description": "The Universal Base Image is designed and engineered to be the base layer for all of your containerized applications, middleware and utilities. This base image is freely redistributable, but Red Hat only supports Red Hat technologies through subscriptions for Red Hat products. This image is maintained by Red Hat and updated regularly.",
"distribution-scope": "public",
"io.k8s.description": "The Universal Base Image is designed and engineered to be the base layer for all of your containerized applications, middleware and utilities. This base image is freely redistributable, but Red Hat only supports Red Hat technologies through subscriptions for Red Hat products. This image is maintained by Red Hat and updated regularly.",
"io.k8s.display-name": "Red Hat Universal Base Image 8",
"io.openshift.expose-services": "",
"io.openshift.tags": "base rhel8",
"maintainer": "Sonatype <cloud-ops@sonatype.com>",
"name": "ubi8",
"release": "208",
"summary": "Provides the latest release of Red Hat Universal Base Image 8.",
"url": "https://access.redhat.com/containers/#/registry.access.redhat.com/ubi8/images/8.0-208",
"vcs-ref": "592956edf47ff0ce45123f240898eabb469ac836",
"vcs-type": "git",
"vendor": "Sonatype",
"version": "8.0"
}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 610620831,
"VirtualSize": 610620831,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/1efc97c10191da75fce41b0da8f423b59a5d96ffb89e7b07d012ee1a64864c51/diff:/var/lib/docker/overlay2/aee2ffe75b92dc90ab960b6e7feb49474fabe44bed6529116a554a3ebf6e5c73/diff:/var/lib/docker/overlay2/5125a1abfcbbea486e7c0df81a40681797c24ff30e3bdbca477f0cb06964266d/diff",
"MergedDir": "/var/lib/docker/overlay2/9ab78069111e94162980242cf5beb5a0591b29139ffb3bb21cac942a5a7ed14d/merged",
"UpperDir": "/var/lib/docker/overlay2/9ab78069111e94162980242cf5beb5a0591b29139ffb3bb21cac942a5a7ed14d/diff",
"WorkDir": "/var/lib/docker/overlay2/9ab78069111e94162980242cf5beb5a0591b29139ffb3bb21cac942a5a7ed14d/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:6866631b657ec5662f4faf948c771d9585a8ea005b1373360ada0a4507cd5c09",
"sha256:48905dae401049ac43befb4f900a6aa0b5d30119db1f0cd0cca92980e0040ad0",
"sha256:1e090454f289654b091f9c9c874c269968a8367657b0f2da1487d456c690fe13",
"sha256:ca9d13755b9ef70fc1e01592d491fecd5661950812aa5bf1e0f4379254551c6b"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
运行nexus容器
develop@ubuntu:~$ docker run -id --privileged=true --name nexus3 --restart=always -p 8081:8081 -v /data/nexus3/nexus-data/:/nexus-data sonatype/nexus3:latest
6cea2db83fc4f708a5278e01a1cc6347f05b065102b3c85f4d49ae5ca3b6e6b3
解释:
8081 端口是 nexus 的服务访问端口 8082 端口是用于 host 镜像仓库的服务端口 8083 端口用户 group 镜像仓库的服务端口
-id 创建守护式容器 --privileged=true 授予root权限(挂载多级目录必须为true,否则容器访问宿主机权限不足) --name=名字 给你的容器起个名字 -p 宿主机端口:容器端口映射 -v 宿主机目录:容器目录 目录挂载
查看容器日志
develop@ubuntu:~$ docker container logs -f nexus3
2019-10-31 03:51:06,996+0000 INFO [FelixStartLevel] *SYSTEM org.sonatype.nexus.pax.logging.NexusLogActivator - start
2019-10-31 03:51:07,702+0000 INFO [FelixStartLevel] *SYSTEM org.sonatype.nexus.features.internal.FeaturesWrapper - Fast FeaturesService starting
2019-10-31 03:51:09,267+0000 WARN [FelixStartLevel] *SYSTEM uk.org.lidalia.sysoutslf4j.context.SysOutOverSLF4JInitialiser - Your logging framework class org.ops4j.pax.logging.slf4j.Slf4jLogger is not known - if it needs access to the standard println methods on the console you will need to register it by calling registerLoggingSystemPackage
2019-10-31 03:51:09,270+0000 INFO [FelixStartLevel] *SYSTEM uk.org.lidalia.sysoutslf4j.context.SysOutOverSLF4J - Package org.ops4j.pax.logging.slf4j registered; all classes within it or subpackages of it will be allowed to print to System.out and System.err
2019-10-31 03:51:09,277+0000 INFO [FelixStartLevel] *SYSTEM uk.org.lidalia.sysoutslf4j.context.SysOutOverSLF4J - Replaced standard System.out and System.err PrintStreams with SLF4JPrintStreams
2019-10-31 03:51:09,279+0000 INFO [FelixStartLevel] *SYSTEM uk.org.lidalia.sysoutslf4j.context.SysOutOverSLF4J - Redirected System.out and System.err to SLF4J for this context
...
注意: 运行容器后访问主机+配置的宿主机映射端口无反应时,请稍等几分钟(视配置时间长短不一),等待nexus3完成初始化才能访问成功
访问nexus3
确保正常启动后 使用浏览器访问http://服务器ip:8081
/nexus-data/admin.password
登录配置
sudo cat /var/lib/docker/volumes/[volume_id]/_data/admin.password
点击右上角登录 账号密码:admin/[admin123]
查看仓库
登录后点击设置界面 选择Repositories,点击Create repository
选择仓库类型 这里选择hosted类型
配置仓库 该仓库指定一个唯一的名称、HTTP的端口、允许交互的API等
No Comments