Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to push image to Harbor in Docker

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to push the image to Harbor in Docker, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!

1. Create a user on Harbor

As shown in figure 1.1 below, "Users"-> "NEW USER", then an input box pops up to enter a user name, password, etc., which will be used later

Figure 1.1

2. Harbor create a project

As shown in figure 2.1 below, "Projects"-> "NEW PROJECT", then an input box will pop up to enter the project name project (enter according to your own needs).

Figure 2.1

After the above, click to enter the project project we just created, then click "Members"-> "+ USER" as shown below, enter the user name created in figure 1.1, and set Role to developer, then you will have permissions for push and pull images.

Figure 2.2

If we push the image to Harbor, then the format of the image name is required. Let's see, as shown in figure 2.3 below, start with 192.168.33.5/project/, which is fixed.

Figure 2.3

3. Push the image locally to the Harbor

Modify the / etc/docker/daemon.json of the native Host, if there is no such file, create it, and append "192.168.33.5" to the value of "insecure-registries" in it, as shown in List-3.1 below, the most important thing is "insecure-registries": ["192.168.33.5"], otherwise we will report an error when we login or push the image to 192.168.33.5.

List-3.1

{"bip": "172.172.172.1 bip 24", "insecure-registries": ["10.221.128.52", "192.168.33.5"]}

Then execute the following List-3.2 command on the local machine

List-3.2

[root@localhost data] # systemctl daemon-reload [root@localhost data] # systemctl restart docker

Then let's see if we can log in to 192.168.33.5, as shown in List-3.3

List-3.3 Username and Password are the ones we created in figure 1.1.

[root@localhost data] # docker login 192.168.33.5Username (mjduan): mjduanPassword: Login Succeeded [root@localhost data] #

Let's push a nginx image to Harbor.

First, name the format of the nginx image locally as shown in figure 2.3, as follows: List-3.4

List-3.4

Mjduan@mjduan-ubuntu:~$ docker tag nginx:1.14 192.168.33.5/project/nginx:1.0

Push the image 192.168.33.5/project/nginx:1.0 to the Harbor as follows. Note that you must log in to push the image first, as shown in List-3.5

List-3.5

Mjduan@mjduan-ubuntu:~$ docker login 192.168.33.5Username (mjduan): Password: Login Succeededmjduan@mjduan-ubuntu:~$ docker push nginx:1.14 192.168.33.5/project/nginx:1.0

Let's take a look in Harbor, as shown in figure 3.1 below. Click to enter the project project you just created, and then you will see the image we have just uploaded to push.

Figure 3.1

The above is all the content of the article "how to push Image to Harbor in Docker". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report