Use the Nexus Repository Manager to build a private docker repository

Install Nexus3 using container

1. Download the image of nexus3 :

docker pull sonatype/nexus3

2. Start a container with the image:

docker run -d --name nexus  --restart=always -p 5000:5000 -p 8081:8081 sonatype/nexus3

Note: Port 5000 is the service port for the mirror repository, port    8081 is the service port for nexus

3. After startup, we can access it through http://server IP:8081.

The default account password is admin/admin123

 

Create a Docker private repository

Access Nexus via browser: 
http://serverIP:8081

Click on the upper right corner to log in, log in with the initial username and password (admin/admin123):

 

Click the Settings interface, select Repositories, and click Create repository, as shown in the following figure: 

 

Select the warehouse type. There are three types of Docker here, namely group, hosted, and proxy. Only the hosted type is demonstrated here, so choose docker(hosted), as shown below: 

Note: The meaning of the Docker image repository type is explained as follows:
  hosted : local storage, that is, the same as the official docker repository, which provides local private server functions

  proxy : Provides the type of proxy for other warehouses, such as the docker central warehouse

  group : group type, the essence is to combine multiple warehouses into one address

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

Because we do not use encrypted HTTPS for access when we test, we need to add a docker startup parameter and specify the address of the private library for him, as follows:

Edit /etc/docker/daemon.json to add the following content, of course, it can also be added through startup parameters

{

   "insecure-registries":["http://172.17.9.81:5000"]

}

Restart the docker process: systemctl restart docker

View docker information: docker info , it is normal to have the following output

 

Log in to the private library

To use the private library to upload and download, you need to log in to connect to Nexus

  docker login http://172.17.9.81:5000/repository/docker-assoft/

Docker upload image to private library

Use docker tag to manage images (must do this)

  Docker tag usage format:

    docker tag SOURCE_IMAGE[:TAG]  TARGET_IMAGE[:TAG]

  docker tag portainer-temlates-new:latest 172.17.9.81:5000/portainer-templates:v1

  docker push 172.17.9.81:5000/portainer-templates:v1

Legend: Marking with tag , the result of normal upload

 

Legend: If tag marking is not performed, a denied: requested access to the resource is denied error will appear

 

 

After the upload is complete , you can see this image in the corresponding docker library in nexus

 

 

Download the mirror in the private library

1. Delete the image in the local experiment above (docker rmi 172.17.9.81:5000/portainer-templates:v1)

 

2docker pull 172.17.9.81:5000/portainer-templates:v1

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325023188&siteId=291194637