How to create a Docker repository using Nexus

How to create a Docker repository using Nexus

The warehouse created using the official Docker Registry faces such problems. For example, the space will not be reclaimed by default after deleting the image, resulting in space being occupied. A common approach is to use Nexus to manage an enterprise's toolkit.

Nexus can not only create Docker repositories, but also NPM, Maven and other types of repositories.

Start the Nexus container

$ docker run -d --name nexus3 --restart=always \
  -p 8081:8081 \
  -p 8082:8082 \
  --mount src=nexus-data,target=/nexus-data \
  sonatype/nexus3
Unable to find image 'sonatype/nexus3:latest' locally
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
f637e039214978f8aac41e621e51588bd8cd8438055498c4060fbaf87799e64f

Among them, 8081 is the access port of Nexus, and 8082 is the port of the warehouse. Most articles on the Internet do not add the mapping of port 8082, which caused me to be stuck for a long time during testing.

Wait a minute or two and open domain:8081 in the browser.

Click Sign in in the upper right corner to log in. The initial account is admin. The password can be entered into the container through the exec command. View the initial password according to the prompted path.

Enter the container to view the initial password

$ docker exec -it f637 /bin/bash
bash-4.4$ vi /nexus-data/admin.password

After logging in, you will be asked to change your password, which will be used in the future.

Create a warehouse

Click the gear button in the navigation to enter the settings page, go to Repository->Repositories, click Create repository and select docker (hosted)

docker (hosted) is a local warehouse, docker (proxy) is a proxy warehouse, and docker (group) is an aggregate warehouse. This article only introduces the local warehouse. If you are interested, you can also search the Internet for the usage of the other two warehouses.

Just fill in the red box in the above picture. Name is the warehouse name, and the HTTP input box is the port number 8082. After writing, scroll to the bottom of the page and click Create repository to create the warehouse.

Adding Access Permissions

Menu Security->Realms Move Docker Bearer Token Realm to the right box to save.

Add user rules: Menu Security->Roles->Create role Search for docker in the Privlleges option Move the corresponding rules to the box on the right and save.

Add user: Menu Security->Users->Create local user. In the Roles option, select the rule you just created and move it to the right window to save it.

Log in to the warehouse

Because the created warehouse is accessed via HTTP, you need to modify the Daemon in the Docker configuration before logging in.

{ "insecure-registries": ["domain:8082"] }

$ docker login domain:8082
Username: yourName
Password:
Login Succeeded

The contents of uploading warehouse, downloading warehouse, and searching warehouse are the same as those in the previous article, so I will not go into details here.

One thing to note is that when starting Nexus, you need to map the warehouse port to the host machine.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Use nexus as a private library to proxy docker to upload and download images
  • Using Docker to build a Nexus private warehouse to implement Maven private service

<<:  Detailed analysis of the blocking problem of js and css

>>:  MySQL 5.7.17 winx64 decompression version installation and configuration method graphic tutorial

Recommend

How to reduce the memory and CPU usage of web pages

<br />Some web pages may not look large but ...

Do you know how many connections a Linux server can handle?

Preface First, let's see how to identify a TC...

Mysql Sql statement comments

You can add comments to MySQL SQL statements. Her...

Docker implements cross-host container communication based on macvlan

Find two test machines: [root@docker1 centos_zabb...

my.cnf parameter configuration to optimize InnoDB engine performance

I have read countless my.cnf configurations on th...

How to make your JavaScript functions more elegant

Table of contents Object parameters using destruc...

The use of textarea in html and common problems and case analysis

The textarea tag is an HTML tag that we often use....

Detailed explanation of how Vue components transfer values ​​to each other

Table of contents Overview 1. Parent component pa...

How to find websites with SQL injection (must read)

Method 1: Use Google advanced search, for example...

The solution of html2canvas that pictures cannot be captured normally

question First, let me talk about the problem I e...

How to enable slow query log in MySQL

1.1 Introduction By enabling the slow query log, ...

CSS stacking and z-index example code

Cascading and Cascading Levels HTML elements are ...

Implementation steps for installing Redis container in Docker

Table of contents Install Redis on Docker 1. Find...

Javascript Basics: Detailed Explanation of Operators and Flow Control

Table of contents 1. Operator 1.1 Arithmetic oper...