harbor私有镜像仓库及docker-compose

harbor私有镜像仓库

pip包管理器

查看python版本

[root@docker1 ~]# python --version
Python 2.7.5

下载pip

[root@docker1 ~]# yum -y install python2-pip

查看已下载的python的依赖库

[root@docker1 ~]# pip list

backports.ssl-match-hostname (3.5.0.1)

configobj (4.7.2)

decorator (3.4.0)

iniparse (0.4)

ipaddress (1.0.16)

perf (0.1)

pip (8.1.2)

pycurl (7.19.0)

pygobject (3.22.0)

pygpgme (0.3)

pyliblzma (0.5.3)

python-linux-procfs (0.4.9)

pyudev (0.15)

pyxattr (0.5.1)

schedutils (0.4)

setuptools (0.9.8)

slip (0.4.0)

slip.dbus (0.4.0)

urlgrabber (3.10)

yum-metadata-parser (1.1.4)

升级pip并指定版本,2.0最高版本就是20.3

[root@docker1 ~]# pip install --upgrade pip==20.3  -i Simple Index

Collecting pip==20.3

  Downloading https://mirrors.aliyun.com/pypi/packages/55/73/bce122d1ed0217b3c1a3439ab16dfa94bbeabd0d31755fcf907493abf39b/pip-20.3-py2.py3-none-any.whl (1.5MB)

    0% |▏                               | 10kB 350kB/s eta 0:0

    1% |▍                               | 20kB 347kB/s eta 0:0

...

    100% |████████████████████████████████| 1.5MB 210kB/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.3

查看版本

[root@docker1 ~]# pip --version

pip 20.3 from /usr/lib/python2.7/site-packages/pip (python 2.7)

下载安装docker-compose

[root@docker1 ~]# pip install docker-compose --ignore-installed requests  -i Simple Index

查看pip版本

[root@docker1 ~]# pip list

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at Release process - pip documentation v24.3.dev0 pip 21.0 will remove support for this functionality.

Package                            Version

---------------------------------- -----------

attrs                              21.4.0

backports.shutil-get-terminal-size 1.0.0

backports.ssl-match-hostname       3.7.0.1

bcrypt                             3.1.7

cached-property                    1.5.2

certifi                            2021.10.8

cffi                               1.15.1

chardet                            4.0.0

configobj                          4.7.2

configparser                       4.0.2

contextlib2                        0.6.0.post1

cryptography                       3.3.2

decorator                          3.4.0

distro                             1.6.0

docker                             4.4.4

docker-compose                     1.26.2   #版本大于1.18即可

dockerpty                          0.4.1

docopt                             0.6.2

enum34                             1.1.10

functools32                        3.2.3.post2

idna                               2.10

importlib-metadata                 2.1.3

iniparse                           0.4

ipaddress                          1.0.23

jsonschema                         3.2.0

paramiko                           2.12.0

pathlib2                           2.3.7.post1

perf                               0.1

pip                                20.3

pycparser                          2.21

pycurl                             7.19.0

pygobject                          3.22.0

pygpgme                            0.3

pyliblzma                          0.5.3

PyNaCl                             1.4.0

pyrsistent                         0.16.1

python-dotenv                      0.18.0

python-linux-procfs                0.4.9

pyudev                             0.15

pyxattr                            0.5.1

PyYAML                             5.4.1

requests                           2.27.1

scandir                            1.10.0

schedutils                         0.4

setuptools                         44.1.1

six                                1.16.0

slip                               0.4.0

slip.dbus                          0.4.0

subprocess32                       3.5.4

texttable                          1.7.0

typing                             3.10.0.0

urlgrabber                         3.10

urllib3                            1.26.19

websocket-client                   0.59.0

yum-metadata-parser                1.1.4

zipp                               1.2.0

WARNING: You are using pip version 20.3; however, version 20.3.4 is available.

You should consider upgrading via the '/usr/bin/python2 -m pip install --upgrade pip' command.

安装docker

[root@docker1 ~]# source docker.sh

[root@docker1 ~]# docker --version

Docker version 26.1.4, build 5650f9b

上传harbor

[root@docker1 ~]# ls

anaconda-ks.cfg  harbor-offline-installer-v2.11.1.tgz

docker.sh        initserver.sh

解压harbor

[root@docker1 ~]# tar -zxvf harbor-offline-installer-v2.11.1.tgz

harbor/harbor.v2.11.1.tar.gz

harbor/prepare

harbor/LICENSE

harbor/install.sh

harbor/common.sh

harbor/harbor.yml.tmpl

[root@docker1 ~]# ls

anaconda-ks.cfg  harbor-offline-installer-v2.11.1.tgz

docker.sh        initserver.sh

harbor

进入解压后的harbor目录

[root@docker1 ~]# cd harbor/

[root@docker1 harbor]# ls

common.sh              harbor.yml.tmpl  LICENSE

harbor.v2.11.1.tar.gz  install.sh       prepare

复制harbor配置文件的模板文件

[root@docker1 harbor]# cp harbor.yml.tmpl harbor.yml

[root@docker1 harbor]# ls

common.sh              harbor.yml       install.sh  prepare

harbor.v2.11.1.tar.gz  harbor.yml.tmpl  LICENSE

修改配置文件---hatbor.yml

[root@docker1 harbor]# vim harbor.yml

修改hostname,注释https

再往下翻找有一个账号和密码,可以不改

执行prepare

[root@docker1 harbor]# ./prepare

prepare base dir is set to /root/harbor

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

See 'docker run --help'.

发现没有启动docker

启动docker之前需要修改daemon.json文件和docker文件

为了方便,从其他主机传一个docker修改一下即可

[root@docker1 harbor]# scp root@192.168.1.50:/etc/docker/daemon.json /etc/docker/

The authenticity of host '192.168.1.50 (192.168.1.50)' can't be established.

ECDSA key fingerprint is SHA256:UHAU+sXTEKYh1El+VOBaor4NjGsmwOi0Cz/Iwdcf5OQ.

ECDSA key fingerprint is MD5:ef:a6:e8:1a:c3:ce:7e:f4:c9:4e:a0:a5:4e:f6:a1:2b.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.1.50' (ECDSA) to the list of known hosts.

root@192.168.1.50's password:

daemon.json                 100%  410   427.7KB/s   00:00

修改daemon.json文件

[root@docker1 harbor]# vim /etc/docker/daemon.json

修改docker文件

[root@docker1 harbor]# vim /usr/lib/systemd/system/docker.service

重新加载,启动docker

[root@docker1 harbor]# systemctl daemon-reload

[root@docker1 harbor]# systemctl start docker

执行prepare,发现没有镜像,自动下载镜像

[root@docker1 harbor]# ./prepare

prepare base dir is set to /root/harbor

Unable to find image 'goharbor/prepare:v2.11.1' locally

v2.11.1: Pulling from goharbor/prepare

21fde6fe7256: Pull complete

e7d411dc7b71: Pull complete

956686c6154d: Pull complete

ccc241b37d9f: Pull complete

3987a6241b04: Pull complete

e5d1bb106ead: Pull complete

ab6fb87032e7: Pull complete

b4af08cd7f0c: Pull complete

55da78465c7e: Pull complete

cccf92d2dec0: Pull complete

Digest: sha256:35dbf7b4293e901e359dbf065ed91d9e4a0de371898da91a3b92c3594030a88c

Status: Downloaded newer image for goharbor/prepare:v2.11.1

WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https

Generated configuration file: /config/portal/nginx.conf

Generated configuration file: /config/log/logrotate.conf

Generated configuration file: /config/log/rsyslog_docker.conf

Generated configuration file: /config/nginx/nginx.conf

Generated configuration file: /config/core/env

Generated configuration file: /config/core/app.conf

Generated configuration file: /config/registry/config.yml

Generated configuration file: /config/registryctl/env

Generated configuration file: /config/registryctl/config.yml

Generated configuration file: /config/db/env

Generated configuration file: /config/jobservice/env

Generated configuration file: /config/jobservice/config.yml

Generated and saved secret to file: /data/secret/keys/secretkey

Successfully called func: create_root_cert

Generated configuration file: /compose_location/docker-compose.yml

Clean up the input dir

检查端口

[root@docker1 harbor]# netstat -lnput |grep 5000

[root@docker1 harbor]# netstat -lnput |grep 80

关闭防火墙

[root@docker1 harbor]# systemctl stop firewalld

初始化

[root@docker1 harbor]# ./install.sh

启动

[root@docker1 harbor]# docker-compose up -d

浏览器访问

输入用户名和密码登录

查看镜像

[root@docker1 harbor]# docker-compose ps

登录harbor

拉取centos镜像

[root@docker1 harbor]# docker pull nginx

给镜像打标签

[root@docker1 harbor]# docker tag nginx:latest 192.168.1.51/centosnginx:v1
 

上传标签镜像

[root@docker1 harbor]# docker push 192.168.1.51/centosnginx:v1
 

查看推送信息

docker-compose编排

主机地址:192.168.1.52

安装epel

[root@docker2 ~]# yum -y install epel-release

安装python2-pip

[root@docker2 ~]# yum -y install python2-pip

[root@docker2 ~]# pip install --upgrade pip==20.3  -i Simple Index

[root@docker2 ~]# pip install docker-compose  -i Simple Index

安装docker

[root@docker2 ~]# sh docker.sh

创建一个目录

[root@docker2 ~]# mkdir test

进入目录,查看当前工作目录并创建一个html目录,将写好的yaml文件通过scp方式或者xshell上传到docker2主机

[root@docker2 ~]# cd test/

[root@docker2 test]# pwd

/root/test

[root@docker2 test]# mkdir html

使用vscode编写的yml文件内容

发布一个项目

[root@docker2 test]# echo "我是被编排的nginx" > ./html/index.html

为了方便从之前的主机传一个daemon.json文件

[root@docker2 test]# scp root@192.168.1.50:/etc/docker/daemon.json /etc/docker/

修改docker文件,将光标所在行修改如图

[root@docker2 test]# vim /usr/lib/systemd/system/docker.service

修改json文件

[root@docker2 test]# vim /etc/docker/daemon.json

重新加载并重启docker

[root@docker2 test]# systemctl daemon-reload

[root@docker2 test]# systemctl restart docker

运行docker-compose

[root@docker2 test]# docker compose up -d

查看运行的容器

浏览器也是可以访问到的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值