环境:
一台正常的docker服务器
[root@localhost ~]# docker pull docker.io/registry
Using default tag: latest
Trying to pull repository docker.io/library/registry ...
latest: Pulling from docker.io/library/registry
cbdbe7a5bc2a: Pull complete
47112e65547d: Pull complete
46bcb632e506: Pull complete
c1cc712bcecd: Pull complete
3db6272dcbfa: Pull complete
Digest: sha256:8be26f81ffea54106bae012c6f349df70f4d5e7e2ec01b143c46e2c03b9e551d
Status: Downloaded newer image for docker.io/registry:latest
[root@localhost ~]# docker images|grep registry
docker.io/registry latest 2d4f4b5309b1 7 weeks ago 26.2 MB
[root@localhost ~]# mkdir -p /data/registry
[root@localhost ~]# docker run -itd --privileged -p 5000:5000 -v /data/registry:/var/lib/registry --restart=always --name=registry_5000port docker.io/registry
ab497e98b8a09a5984e444e82046391ee70b343f2e1eaf2b2f42ffcac8310e0c
vim /etc/sysconfig/docker
–insecure-registry 192.168.1.12:5000
[root@localhost ~]# vim /etc/sysconfig/docker
# /etc/sysconfig/docker
# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry 192.168.1.12:5000'
if [ -z "${DOCKER_CERT_PATH}" ]; then
DOCKER_CERT_PATH=/etc/docker
fi
#
上传一个centos8镜像至仓库
[root@localhost ~]# docker images|grep centos6
centos6_ssh latest efd998bd6817 6 years ago 297 MB
[root@localhost ~]# docker tag efd998bd6817 192.168.1.12:5000/centos6_ssh
[root@localhost ~]# docker images|grep centos6
192.168.1.12:5000/centos6_ssh latest efd998bd6817 6 years ago 297 MB
centos6_ssh latest efd998bd6817 6 years ago 297 MB
[root@localhost ~]# docker push 192.168.1.12:5000/centos6_ssh
The push refers to a repository [192.168.1.12:5000/centos6_ssh]
5f70bf18a086: Pushed
5dde9e7abaae: Pushed
0d2c9d3bef41: Pushed
26231980c1a5: Pushed
7ec2a9eb1017: Pushed
29e0db08def6: Pushed
9225ac3d0295: Pushed
0f26de94dce0: Pushed
821f107b9dc4: Pushed
latest: digest: sha256:18d681aed592b9061e6358645e1c4d0f46a4b80a63f1628f63bdf7aa6b42f3e2 size: 3019
[root@localhost ~]# ls /data/registry/docker/registry/v2/repositories/
centos6_ssh
[root@localhost ~]# curl -XGET http://192.168.1.12:5000/v2/_catalog
{"repositories":["centos6_ssh"]}
[root@localhost ~]#
[root@localhost ~]# curl -XGET http://192.168.1.12:5000/v2/centos6_ssh/tags/list
{"name":"centos6_ssh","tags":["latest"]}
[root@localhost ~]# docker pull 192.168.1.12:5000/centos6_ssh:latest
Trying to pull repository 192.168.1.12:5000/centos6_ssh ...
latest: Pulling from 192.168.1.12:5000/centos6_ssh
4f4fb700ef54: Pull complete
22aa74e407fb: Pull complete
af486a0a979b: Pull complete
71899e3e76d0: Pull complete
d9a0675e81d8: Pull complete
f3e489d2c920: Pull complete
ccc4b0ee49d1: Pull complete
2eea875c5ec9: Pull complete
ff27d4260cec: Pull complete
Digest: sha256:18d681aed592b9061e6358645e1c4d0f46a4b80a63f1628f63bdf7aa6b42f3e2
Status: Downloaded newer image for 192.168.1.12:5000/centos6_ssh:latest
[root@localhost ~]# docker images|grep centos6
192.168.1.12:5000/centos6_ssh latest efd998bd6817 6 years ago 297 MB
Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源Docker Distribution
Harbor仓库部署两种方式,一种是off-line ,一种是on-line,即离线和在线安装,此处选择离线安装:
安装环境
[root@localhost ~]# yum install epel-release -y
[root@localhost ~]# yum install python-pip -y
[root@localhost ~]# pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/5a/4a/39400ff9b36e719bdf8f31c99fe1fa7842a42fa77432e584f707a5080063/pip-20.2.2-py2.py3-none-any.whl (1.5MB)
100% |████████████████████████████████| 1.5MB 330kB/s
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Successfully installed pip-20.2.2
[root@localhost ~]# pip install docker-compose
......
Successfully installed attrs-19.3.0 backports.shutil-get-terminal-size-1.0.0 bcrypt-3.1.7 cached-property-1.5.1 certifi-2020.6.20 cffi-1.14.1 chardet-3.0.4 configparser-4.0.2 contextlib2-0.6.0.post1 cryptography-3.0 distro-1.5.0 docker-4.3.0 docker-compose-1.26.2 dockerpty-0.4.1 docopt-0.6.2 enum34-1.1.10 functools32-3.2.3.post2 idna-2.10 importlib-metadata-1.7.0 jsonschema-3.2.0 paramiko-2.7.1 pathlib2-2.3.5 pycparser-2.20 pynacl-1.4.0 pyrsistent-0.16.0 python-dotenv-0.14.0 requests-2.24.0 scandir-1.10.0 subprocess32-3.5.4 texttable-1.6.2 typing-3.7.4.3 urllib3-1.25.10 websocket-client-0.57.0 zipp-1.2.0
下载Habor并且解压
[root@localhost ~]# wget -c https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-offline-installer-v1.7.0.tgz
[root@localhost ~]# tar -zxvf harbor-offline-installer-v1.7.0.tgz
[root@localhost ~]# cd harbor
vim harbor.cfg
[root@localhost harbor]# vim harbor.cfg
4 _version = 1.7.0
5 #The IP address or hostname to access admin UI and registry service.
6 #DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
7 #DO NOT comment out this line, modify the value of "hostname" directly, or the installation will fail.
8 hostname = 192.168.1.112
9
10 #The protocol for accessing the UI and token/notification service, by default it is http.
11 #It can be set to https if ssl is enabled on nginx.
12 ui_url_protocol = http
13
14 #Maximum number of job workers in job service
15 max_job_workers = 10
安装
[root@localhost harbor]# ./install.sh
[Step 0]: checking installation environment ...
Note: docker version: 1.13.1
......
Creating nginx ... done
✔ ----Harbor has been installed and started successfully.----
http://192.168.1.112 用户名:admin 密码:Harbor12345,也可以在habor.cnf自己设置密码
创建用户
--------------------end