Kai
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    {%hackmd BJzAwtWvp %} # Learning Nexus Repository (docker) ## What is Nexus Repository? - Sonatype nexus repository is a kind of repository manager. Includes support for Maven, NuGet, PyPI, npm, Bower, RubyGems, Docker, P2, OBR, APT and YUM and many more. In addition to these, it also supports integration with other tools like CICD(Jenkins, Bamboo), IDE(Eclipse, IntelliJ, Visual Studio), etc. - Nexus repository provides two types of repositories, we can check the difference between them from [here](https://www.sonatype.com/products/sonatype-nexus-oss-vs-pro-features). - Nexus Repository OSS: It is an open source repository manager. It is free to use and support all the features of nexus repository. - Nexus Repository Pro: It is a paid repository manager. It provides additional features like support, security, etc. ## What can Nexus Repository do? - Proxy Remote Repositories: - Nexus can act as a proxy for remote repositories, meaning you can access these remote repositories through Nexus instead of connecting to them directly. This can provide better performance and higher availability. - Hosted Private Repositories: - You can use Nexus to create your own private repositories and publish your build products to these repositories. This can provide better control and security. - Group Repositories: - Nexus allows you to create group repositories, which can include multiple other repositories (including proxy repositories and hosted repositories). This can make it easier for you to manage and organize your repositories. - Support for Multiple Package Formats: - Nexus supports multiple package formats, including Maven, NuGet, NPM, Python, RubyGems, and Docker, etc. - Security and Permission Management: - Nexus provides powerful security and permission management features, including user and role management, permission assignment, and LDAP integration, etc. - Smart Proxy and Caching: - Nexus caches all content downloaded from remote repositories and only updates this content when needed. This can provide faster build speeds and higher availability. - Component Health Check: - Nexus provides a component health check feature that can help you identify and fix security and license issues in your repository. ## Let's practice some basic operations by different ways (image version) - Here we use the image version of nexus repository. (You can download the nexus zip from [here](https://help.sonatype.com/repomanager3/product-information/download) as well). - Create a docker-compose.yml file and add the following content: ```yml version: "3.1" services: nexus: image: sonatype/nexus3:3.63.0 container_name: nexus ports: - "8081:8081" - "8082:8082" - "8083:8083" - "8084:8084" restart: unless-stopped volumes: - ./nexus-data:/nexus-data ``` - Use below command to up the service (You need to have docker installed) ``` docker-compose up -d ``` - The default username is admin and password is at "\nexus-data\admin.password". After login, we can change the password and this password file will be deleted. 1. Open our nexus repository: "localhost:8081". 2. Login with our account "admin" and default password. (After login, go change the password.) 3. Go to Security -> Realm, check the Docker Bearer Token Realm has been activated. 4. Go modify your docker daemon settings. 1. Open the docker desktop and click the settings icon. 2. Go to the docker engine tab and "add" the following content: 1. If your url has https, then you don't need to add this. In another hand, if your url is http, then you need to add this. ```json { "insecure-registries": [ "127.0.0.1:8082", "127.0.0.1:8083", "127.0.0.1:8084" ] } ``` 3. Restart the docker desktop. ### Docker image situation - There are three types of repositories for docker. - docker(hosted): This type of repository is used to store and distribute your own docker images. It is a private repository. - docker(proxy): This type of repository allows you to proxy remote docker repositories. For example, if you want to proxy the docker hub, you can create a docker(proxy) repository and configure it to proxy the docker hub. Then you don't need to download the docker images from the docker hub, you can download them from your own nexus repository. - docker(group): This type of repository allows you to combine mutiple docker repositories into a single repository. For example, if you have two docker repositories, one is docker(hosted) and another is docker(proxy). You can create a docker(group) repository and add these two repositories into it. Then you can download the docker images from the docker(group) repository. #### Docker(hosted) repository 1. Go setting icon -> Repositories -> Create repository. 2. Choose the type as "docker(hosted)". 1. Give it a name as "docker-hosted-test". 2. Give it a HTTP port as "8082". 3. Tick the "Allow anonymous docker pull" checkbox. 4. Tick the "Enable Docker V1 API" checkbox. 5. Save it. 3. Open a command line and login to the nexus repository to check if it works. ```bash docker login 127.0.0.1:8082 username: <your username> password: <your password> ``` Now, everything is ready. Let's pull a official docker image (nginx) , then tag it and push it to our nexus repository. 4. Pull the official nginx image. ```bash docker pull nginx ``` 5. Tag the image. ```bash docker tag nginx 127.0.0.1:8082/nginx ``` 6. Push the image to our nexus repository. ```bash docker push 127.0.0.1:8082/nginx ``` 7. Go to the nexus repository and check if the image has been pushed successfully. On the page, click the "Browse" button and select the "docker-hosted-test" repository. Then we can see the image we just pushed. ![image](https://hackmd.io/_uploads/SJVw-WTua.png) 8. Now, we can run the image from our nexus repository and specify the port. ```bash docker run -d -p 8080:80 127.0.0.1:8082/nginx:latest ``` --- Damn! It spent me a lot of time to make it work. I don't know why but it works now. Still need to understand how does it work and what abilities does it have. --- #### Docker(proxy) repository 1. Go setting icon -> Blob Stores -> Create blob store. 1. Choose the type as "File". 2. Give it a name as "docker-hub". 3. The path will be set automatically. Leave the Enable checkbox unticked. 4. Save it. 2. Go setting icon -> Repositories -> Create repository. 1. Give it a name as "docker-proxy-test". 2. Give it a HTTP port as "8083". 3. Tick the "Allow anonymous docker pull" checkbox. 4. Tick the "Enable Docker V1 API" checkbox. 5. Give the Remote storage as "https://registry-1.docker.io". 6. Choose the Docker index as "Docker Hub" in this case. 7. Choose the Blob store as "docker-hub". 8. Save it. 4. Open a command line and login to the nexus repository to check if it works. ```bash docker login 127.0.0.1:8083 username: <your username> password: <your password> ``` 5. Here we use Ubuntu on the docker hub to test if it works. 1. Logout the previous nexus repository. ```bash docker logout 127.0.0.1:8082 ``` 2. login to the new nexus repository. ```bash docker login 127.0.0.1:8083 username: <your username> password: <your password> ``` 3. Pull the image from the docker hub. ```bash docker pull 127.0.0.1:8083/ubuntu ``` 6. Wala! It works! Go to the nexus repository and check if the image has been pulled successfully. On the page, click the "Browse" button and select the "docker-proxy-test" repository. Then we can see the image we just pulled. ![image](https://hackmd.io/_uploads/B1JuW-6_a.png) #### Docker(group) repository Basically, Docker(group) repository is a combination of Docker(hosted) and Docker(proxy) repositories. So, we have alreadly established these two repository in the previous steps. Now, we just need to create a Docker(group) repository and add these two repositories into it. 1. Go setting icon -> Repositories -> Create repository. 1. Give it a name as "docker-group-test". 2. Give it a HTTP port as "8084". 3. Tick the "Allow anonymous docker pull" checkbox. 4. Tick the "Enable Docker V1 API" checkbox. 5. Choose the Bolb store as "docker-hub". 6. In member repositories section, add the "docker-hosted-test" and "docker-proxy-test" repositories. 7. Save it. 2. Open a command line and login to the nexus repository to check if it works. ```bash docker login 127.0.0.1:8083 username: <your username> password: <your password> ``` 3. Now, delete the images we pulled before. ```bash docker images docker rmi <image id> ``` 4. Pull the image from the docker(group) repository. 1. Logout the previous nexus repository. ```bash docker logout 127.0.0.1:8083 ``` 2. login to the new nexus repository. ```bash docker login 127.0.0.1:8084 username: <your username> password: <your password> ``` 3. Pull the image from the docker(group) repository. ```bash docker run -d -p 8080:80 127.0.0.1:8084/nginx:latest docker pull 127.0.0.1:8084/ubuntu ``` 5. If you want to push image to the docker(group) repository, you need to pay for pro version. So, I will skip this part. You can refer to the official document [here](https://help.sonatype.com/repomanager3/nexus-repository-administration/formats/docker-registry/pushing-images-to-a-group-repository). ### Java library (jar) situation ### Angular library (npm) situation ---------------------------------------------- - Q: How to delete docker images from nexus repository? - A: I use several ways to delete the images from nexus repository. But I can't delete all the file which is assocated with the specic image. You can check the official document below and try it by yourself. - [how to delete docker images form nexus repository3](https://support.sonatype.com/hc/en-us/articles/360009696054-How-to-delete-docker-images-from-Nexus-Repository-3)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully