An overview,

Nexus3 can support Maven, Docker, NuGet, NPM, Bower, etc., as a stable private server product is often used in our development and management process.

Using Nexus to build a local private server has the following benefits:

  1. Accelerate construction and stability
  2. Save bandwidth
  3. Unified control, convenient supervision
  4. Custom artifacts can be deployed

These advantages make Nexus increasingly one of the mainstream warehouse managers

Without further ado, above



Two, Nexus image installation

Nexus2 还是 Nexus3

The Nexus3.x is a big change from the 2.x version

  1. Refactoring from the bottom to improve performance, enhance scalability, and improve the user experience
  2. Upgrade the interface to add more browsing, search and management functions
  3. Added Docker, NuGet, NPM, Bower support
  4. Provides a new management interface to automatically manage tasks

Nexus3 installation

1. Download the Nexus3 image

Visit hub.docker.com/ and search for nexus



Select the first one, the official original import version, and execute the following command, which I have downloaded here

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
Copy the code

2. Start a container using the image

$ docker run -d -p 8081:8081 -p 8082:8082 -p 8083:8083 --name nexus3 -v /home/nexus/nexus-data:/nexus-data --restart=always sonatype/nexus3Copy the code

  • Port 8082 is the service port for the host mirroring repository
  • 8083 Port User group Service port of the mirror vault
  • Port 8081 is the service port of the Nexus
  • –name nexus3
  • -v /home/nexus/nexus-data:/nexus-data Mount the nexus-data data folder in the container to the /home/nexus/nexus-data directory on the host
  • Sonatype/Nexus3 Image name. If the latest version is not followed by the version number, the latest version is enabled by default

Note –restart=always: With this directive always restart the container regardless of the exit status code. When always is specified, the Docker Daemon will restart the container an unlimited number of times. The container also tries to restart the daemon when it starts, regardless of the state of the container at the time.

  • No: Do not restart the container when it exits. This is the default.
  • On-failure [:max-retries] : restarts only when the container exits with a non-zero status code. Optionally, the number of times you can exit the Docker Daemon and try to restart the container.
  • Always: Always restarts the container regardless of the exit status code. When always is specified, the Docker Daemon will restart the container an unlimited number of times. The container also tries to restart the daemon when it starts, regardless of the state of the container at the time.
  • Unless -stopped: Always restart the container regardless of the exit status code, but do not try to start the container if it is already stopped when the daemon starts.

After the startup, we can access the server through http://server IP:8081. The related interface is shown in the following figure





The default account of nexus3 is admin, but the password has been changed. The password is stored in the admin.password file in the Nexus-data directory of the Nexus3 container.

A. View the Nexus3 container ID and run docker ps

Console display

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 registrybCopy the code

B. Go to the container console and run docker exec it 01B398d530aa bash

Console display

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$cdNexus-data/bash-4.4$ls admin.password db generated-bundles karaf.pidlog     restore-from-backup
blobs           elasticsearch  instances          keystores  orient  tmp
cache           etc            javaprefs          lock       portadCopy the code

The first line in admin.password is the password. Log in with admin to copy the password, and the system will automatically prompt you to change the admin password after successful login

Nexus creates Docker private repository

Access the Nexus through a browser

http://server IP address :8081

Log on to the nexus

Click on the upper right corner to log in, and the password is the one you just set:



The login

Create repository

Go to the Settings screen, select Repositories, and click Create Repository, as shown below:



Select the Warehouse type

Docker is divided into three types: Group, Hosted, and Proxy. Select Docker (Hosted) as shown below:



Three types of warehouse

Note: The meanings of Docker image warehouse types are explained as follows:

  • Hosted: Local storage, which provides the same local private server functions as the Official Docker repository
  • Proxy: Provides a type of proxy for other repositories, such as a Docker central repository
  • Group: A group type that essentially combines multiple warehouses into one address
Create a host repository

Specify the docker repository name, specify a port to access the repository via HTTP, check whether support docker API V1, and then create repository;




The host repository is created successfully

Verify the warehouse

I have logged in to the warehouse locally, and it shows success directly. The account password can be admin or configured in the Nexus, so I won’t repeat it here

Docker login 10.10.1.10:8082 Authenticating with Existing credentials... WARNING! Your password will be stored unencryptedin /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login SucceededCopy the code

Docker handy notes 2 – configuring ali mirror accelerator, based on Ubuntu18.04LTS