本地容器镜像仓库Harbor
1.1.1.1 获取YUM源
使用阿里云开源软件镜像站。
# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
1.1.1.2 安装并设置启动及开机自启动
# yum -y install docker-ce
# systemctl enable --now docker
1.1.2 docker compose安装
下载docker-compose二进制文件
链接:https://pan.baidu.com/s/1DUeve1D8ClBNyz5dnuCcog?pwd=80u7
提取码:80u7
--来自百度网盘超级会员V3的分享
~~~powershell
查看已下载二进制文件
# ls
docker-compose-Linux-x86_64
移动二进制文件到/usr/bin目录,并更名为docker-compose
# mv docker-compose-Linux-x86_64 /usr/bin/docker-compose
为二进制文件添加可执行权限
# chmod +x /usr/bin/docker-compose
安装完成后,查看docker-compse版本
# docker-compose version
docker-compose version 1.25.0, build 0a186604
docker-py version: 4.1.0
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
1.1.3 获取harbor安装文件
下载harbor离线安装包
链接:https://pan.baidu.com/s/11Uki3Q8yVd-D5ihb3TUzUg?pwd=kd1e
提取码:kd1e
--来自百度网盘超级会员V3的分享
~~~powershell
查看已下载的离线安装包
# ls
harbor-offline-installer-v2.4.1.tgz
1.1.4 修改配置文件
解压harbor离线安装包
# tar xf harbor-offline-installer-v2.4.1.tgz
查看解压出来的目录
# ls
harbor
查看harbor目录
# ls harbor
common.sh harbor.v2.4.1.tar.gz harbor.yml.tmpl install.sh LICENSE prepare
创建配置文件
# cd harbor/
# mv harbor.yml.tmpl harbor.yml
修改配置文件内容
# vim harbor.yml
# Configuration file of Harbor
# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: 192.168.71.122
# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 80
# https related config
# https:
# https port for harbor, default is 443
# port: 443
# The path of cert and key files for nginx
# certificate: /root/harbor/6864844_kubemsb.com.pem
# private_key: /root/harbor/6864844_kubemsb.com.key
# # Uncomment following will enable tls communication between all harbor components
# internal_tls:
# # set enabled to true means internal tls is enabled
# enabled: true
# # put your cert and key files on dir
# dir: /etc/harbor/tls/internal
# Uncomment external_url if you want to enable external proxy
# And when it enabled the hostname will no longer used
# external_url: https://reg.mydomain.com:8433
# The initial password of Harbor admin
# It only works in first time to install harbor
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password: Harbor12345 访问密码
......
1.1.5 执行预备脚本
# ./prepare
1.1.6 执行安装脚本
# ./install.sh
1.1.7 验证运行情况
cat /etc/docker/daemon.json
{
“insecure-registries”: [“192.168.71.122”]
}
重启加载daemon配置
systemctl daemon-reload
重启docker# systemctl restart docker
# docker ps
1.1.8 访问harbor UI界面
1.1.9 docker tag
查看已有容器镜像文件
docker images
为已存在镜像重新添加tag
# docker tag nginx:1.96.7192.168.71.122/tty/nginx:1.96.6
1.1.10 docker push
[root@k8s-worker01 ~]# docker login 192.168.71.122
Username: admin
Password:
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
推送本地容器镜像到harbor仓库
# docker push 192.168.71.122/tty/nginx:1.19.6
1.1.11 docker pull
在其它主机上下载或使用harbor容器镜像仓库中的容器镜像
在本地添加域名解析
# vim /etc/hosts
# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.71.122 www.kubemsb.com
在本地添加/etc/docker/daemon.json文件,其中为本地主机访问的容器镜像仓库
# vim /etc/docker/daemon.json
# cat /etc/docker/daemon.json
{
"insecure-registries": ["192.168.71.122"]
}
# systemctl daemon-reload
# systemctl restart docker
[root@k8s-worker01 ~]# docker login 192.168.71.122
Username: admin
Password:
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
docker pull 192.168.71.122/tty/nginx@sha256:1a53eb723d17523512bd25c27299046cfa034cce309f4ed330c943a304513f59
查看已下载的容器镜像
# docker images