Harbor镜像仓库介绍与安装
2024-03-25 本文已影响0人
灯火楼台666
Harbor镜像仓库介绍与安装(制作自定义镜像) 注意:registry 是docker官方制作镜像工具
[root@192 ~]# cd /usr/local/
[root@192 local]# ls
bin docker etc games gitTest harbor-offline-installer-v2.10.1.tgz include lib lib64 libexec sbin share src test
[root@192 local]# tar -zxvf harbor-offline-installer-v2.10.1.tgz
harbor/harbor.v2.10.1.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml.tmpl
[root@192 local]# ls
bin docker etc games gitTest harbor harbor-offline-installer-v2.10.1.tgz include lib lib64 libexec sbin share src test
[root@192 local]# cd harbor/
[root@192 harbor]# ls
common.sh harbor.v2.10.1.tar.gz harbor.yml.tmpl install.sh LICENSE prepare
[root@192 harbor]# cd ..
[root@192 local]# rm -rf harbor-offline-installer-v2.10.1.tgz
[root@192 local]# ls
bin docker etc games gitTest harbor include lib lib64 libexec sbin share src test
[root@192 local]# cd harbor/
[root@192 harbor]# ls
common.sh harbor.v2.10.1.tar.gz harbor.yml.tmpl install.sh LICENSE prepare
[root@192 harbor]#
root@192 harbor]# cp harbor.yml.tmpl harbor.yml
[root@192 harbor]# ls
common.sh harbor.v2.10.1.tar.gz harbor.yml harbor.yml.tmpl install.sh LICENSE prepare
[root@192 harbor]# vim harbor.yml
[root@192 harbor]# ./install.sh
1616a81e292de9def62fb4734589f771.png
harbor地址/项目名/镜像名:版本
[root@192 harbor]# vim /etc/docker/daemon.json
{
"insecure-registries" : ["192.168.63.128:80"]
}
[root@192 harbor]# docker tag 1d9ebe4625f8 192.168.63.128:80/repo/mytest:v1.0.0
[root@192 harbor]# docker push 192.168.63.128:80/repo/mytest:v1.0.0
[root@192 harbor]# systemctl restart docker
[root@192 docker]# docker push 192.168.63.128:80/repo/mytest:v1.0.0
The push refers to repository [192.168.63.128:80/repo/mytest]
5f70bf18a086: Preparing
e604813a944a: Preparing
50ecdabc71b7: Preparing
3e9cda2eceec: Preparing
bb7b60f93aea: Preparing
0ef3d186e2bd: Waiting
1e0931f30489: Waiting
fd97e4a10f39: Waiting
unauthorized: unauthorized to access repository: repo/mytest, action: push: unauthorized to access repository: repo/mytest, action: push
[root@192 ~]# docker login -u admin -p Harbor12345 192.168.63.128:80
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@192 ~]# docker push 192.168.63.128:80/repo/mytest:v1.0.0
The push refers to repository [192.168.63.128:80/repo/mytest]
5f70bf18a086: Pushed
e604813a944a: Pushed
50ecdabc71b7: Pushed
3e9cda2eceec: Pushed
bb7b60f93aea: Pushed
0ef3d186e2bd: Pushed
1e0931f30489: Pushed
fd97e4a10f39: Pushed
v1.0.0: digest: sha256:10dd80fbd6101c124892401c7f2caae99d28fb1d29b3e93a08325cd78ecc2546 size: 3032
[root@192 ~]#
[root@192 ~]# docker pull 192.168.63.128:80/repo/mytest:v1.0.0
Jenkins容器内部使用Docker
[root@192 ~]# cd /var/run/
[root@192 run]# ll
总用量 60
drwxr-xr-x. 2 root root 100 3月 26 06:49 abrt
-rw-------. 1 root root 11 3月 26 06:49 alsactl.pid
-rw-r--r--. 1 root root 4 3月 26 06:49 atd.pid
-rw-r--r--. 1 root root 4 3月 26 06:49 auditd.pid
drwxr-xr-x. 2 avahi avahi 80 3月 26 06:49 avahi-daemon
drwxr-xr-x. 2 root root 40 3月 26 06:49 certmonger
drwxr-x---. 2 chrony chrony 60 3月 26 07:42 chrony
-rw-r--r--. 1 root root 4 3月 26 06:49 chronyd.pid
drwxr-xr-x. 2 root root 80 3月 26 06:50 console
drwx--x--x. 5 root root 140 3月 26 07:10 containerd
-rw-r--r--. 1 root root 4 3月 26 06:49 crond.pid
----------. 1 root root 0 3月 26 06:49 cron.reboot
drwxr-xr-x. 3 root lp 80 3月 26 06:49 cups
drwxr-xr-x. 2 root root 60 3月 26 06:49 dbus
-rw-r--r--. 1 root root 4 3月 26 07:42 dhclient-ens33.pid
prw-------. 1 root root 0 3月 26 06:49 dmeventd-client
prw-------. 1 root root 0 3月 26 06:49 dmeventd-server
drwx------. 8 root root 180 3月 26 07:36 docker
-rw-r--r--. 1 root root 5 3月 26 07:36 docker.pid
srw-rw----. 1 root docker 0 3月 26 06:49 docker.sock
-rw-------. 1 root root 0 3月 26 06:49 ebtables.lock
drwxr-xr-x. 2 root root 40 3月 26 06:49 faillock
drwx--x--x. 4 root gdm 100 3月 26 06:50 gdm
-rw-------. 1 root root 4 3月 26 06:49 gssproxy.pid
srw-rw-rw-. 1 root root 0 3月 26 06:49 gssproxy.sock
drwxr-xr-x. 4 root root 100 3月 26 06:49 initramfs
-rw-r--r--. 1 root root 4 3月 26 06:49 ksmtune.pid
drwxr-xr-x. 6 root root 220 3月 26 06:49 libvirt
-rw-r--r--. 1 root root 3 3月 26 06:49 libvirtd.pid
drwxr-xr-x. 8 root root 220 3月 26 07:08 lock
drwxr-xr-x. 3 root root 60 3月 26 06:49 log
drwxrwxr-x. 3 root libstoragemgmt 60 3月 26 06:49 lsm
drwx------. 2 root root 80 3月 26 06:49 lvm
-rw-r--r--. 1 root root 4 3月 26 06:49 lvmetad.pid
drwx--x---. 2 root root 40 3月 26 06:49 mdadm
drwxr-xr-x. 2 root root 40 3月 26 06:49 mount
drwxrwxr-x. 2 root root 40 3月 26 06:49 netreport
drwxr-xr-x. 3 root root 100 3月 26 06:49 NetworkManager
drwxr-xr-x. 2 root root 40 3月 26 06:50 plymouth
drwxr-xr-x. 2 root root 40 3月 26 06:49 ppp
drwxr-xr-x. 2 radvd radvd 40 3月 26 06:49 radvd
drwx------. 2 rpc rpc 40 3月 26 06:49 rpcbind
-r--r--r--. 1 root root 0 3月 26 06:49 rpcbind.lock
srw-rw-rw-. 1 root root 0 3月 26 06:49 rpcbind.sock
drwxr-xr-x. 2 root root 40 3月 26 06:49 samba
drwxr-xr-x. 2 root root 40 3月 26 06:49 sepermit
drwxr-xr-x. 2 root root 40 3月 26 06:49 setrans
drwx--x--x. 2 setroubleshoot setroubleshoot 40 3月 26 06:49 setroubleshoot
-rw-------. 1 root root 4 3月 26 06:49 sm-notify.pid
drwxr-xr-x. 2 root root 60 3月 26 06:49 spice-vdagentd
-rw-r--r--. 1 root root 4 3月 26 06:49 sshd.pid
drwx--x--x. 3 root root 60 3月 26 06:49 sudo
drwxr-xr-x. 2 root root 60 3月 26 06:49 sysconfig
-rw-------. 1 root root 3 3月 26 06:49 syslogd.pid
drwxr-xr-x. 17 root root 420 3月 26 07:29 systemd
drwxr-xr-x. 2 root root 60 3月 26 06:49 tmpfiles.d
drwxr-xr-x. 2 root root 60 3月 26 06:49 tuned
drwxr-xr-x. 7 root root 160 3月 26 07:36 udev
drwx------. 2 root root 40 3月 26 06:49 udisks2
drwxr-xr-x. 4 root root 80 3月 26 07:38 user
-rw-rw-r--. 1 root utmp 1920 3月 26 07:38 utmp
drwxr-xr-x. 2 root root 60 3月 26 06:49 vmware
-rw-------. 1 root root 0 3月 26 06:49 xtables.lock
[root@192 run]# chown root:root docker.sock
[root@192 run]# chmod o+rw docker.sock
[root@192 run]# cd /usr/local/docker/jenkins_docker/
[root@192 jenkins_docker]# ls
data docker-compose.yml
[root@192 jenkins_docker]# vim docker-compose.yml
[root@192 jenkins_docker]# docker-compose up -d
[+] Running 1/1
✔ Container jenkins Started 0.1s
[root@192 jenkins_docker]# docker exec -it jenkins bash
jenkins@c4f0dc7b5532:/$ docker version
Client: Docker Engine - Community
Version: 25.0.4
API version: 1.44
Go version: go1.21.8
Git commit: 1a576c5
Built: Wed Mar 6 16:33:16 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 25.0.4
API version: 1.44 (minimum version 1.24)
Go version: go1.21.8
Git commit: 061aa95
Built: Wed Mar 6 16:32:11 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.28
GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0
jenkins@c4f0dc7b5532:/$