一:安装docker。(所有服务器都要安装)
- 安装必要的一些系统工具
c
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
- 添加软件源信息
c
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
c
sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
- 更新并安装Docker-CE
c
sudo yum makecache fast
sudo yum -y install docker-ce
- 开启Docker服务
c
sudo service docker start
- 设置开机自启动
c
systemctl enable docker
- 测试
c
docker version
- 配置加速器,注意:在除了harbor仓库的机器上进行配置
c
cat >> /etc/docker/daemon.json <<-EOF
{
"registry-mirrors": [
"http://74f21445.m.daocloud.io",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
],
"insecure-registries": ["node01"],
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
9.重启docker服务
c
systemctl restart docker
- 检查
c
docker info

二:安装cri-docker。(所有服务器都要安装)
1.下载安装。
c
mkdir -p /data/softs
cd /data/softs
wget https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.2/cri-dockerd-0.3.2.amd64.tgz
- 解压软件
c
tar xf cri-dockerd-0.3.2.amd64.tgz
mv cri-dockerd/cri-dockerd /usr/local/bin/
- 检查效果
c
cri-dockerd --version

- 创建 cri-docker.service
c
cat > /etc/systemd/system/cri-docker.service <<-EOF
[Unit]
Description=CRI Interface for Docker Application Container Engine
Documentation=https://docs.mirantis.com
After=network-online.target firewalld.service docker.service
Wants=network-online.target
Requires=cri-docker.socket
[Service]
Type=notify
ExecStart=/usr/local/bin/cri-dockerd --container-runtime-endpoint fd://
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process
[Install]
WantedBy=multi-user.target
EOF
- 创建 cri-docker.socket
c
cat > /etc/systemd/system/cri-docker.socket <<-EOF
[Unit]
Description=CRI Docker Socket for the API
PartOf=cri-docker.service
[Socket]
ListenStream=%t/cri-dockerd.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
EOF
- 启动cri-docker
c
sudo systemctl daemon-reload
sudo systemctl start cri-docker
sudo systemctl status cri-docker
三:安装harbor。(指定一台)
- 安装docker-compose.
c
yum -y insta11 docker-compose
- 下载软件.
c
mkdir /data/{softs,server} -p && cd /data/softs
wget https://ghproxy.com/https://github.com/goharbor/harbor/releases/download/v2.5.0/harbor-offline-installer-v2.5.0.tgz
tar -zxvf harbor-offline-installer-v2.5.0.tgz
mv harbor /data/server/harbor
cd /data/server/harbor/
- 加载镜像。
c
docker load < harbor.v2.5.0.tar.gz
docker images

- 备份配置。
c
cp harbor.yml.tmpl harbor.yml
vim harbor.yml
1. 更换名称
2. 禁用http的服务
3. 更改密码
4. 设置数据路径。


./prepare
./install.sh
docker-compose ps

- 定制服务启动文件。
c
docker-compose down
vim /etc/systemd/system/harbor.service
c
[Unit]
Description=Harbor
After=docker.service systemd-networkd.service systemd-resolved.service
Requires=docker.service
Documentation=http://github.com/vmware/harbor
[Service]
Type=simp1e
Restart=on-failure
RestartSec=5
#需要注意harbor的安装位置
ExecStart=/usr/bin/docker-compose --file /data/server/harbor/docker-compose.yml up
ExecStop=/usr/bin/docker-compose --file /data/server/harbor/docker-compose.yml down
[Install]
WantedBy=multi-user.target
c
加载服务配置文件
systemctl daemon-reload
启动服务
systemctl start harbor
检查状态
systemctl status harbor
设置开机自启动
systemctl enable harbor
docker-compose ps

四. 页面化定制仓库。
- 新建用户。
- 新建项目。
- 如何提交镜像。
第一步:镜像打标签。
格式: docker tag 服务名称 harbor地址/仓库名称/服务器名称:对应版本号
c
docker tag aaa node01/zzy/aaa:v01
第二步:登录harbor。
第三步:提交镜像。
docker push harbor地址/仓库名称/服务器名称:对应版本号
案例:所有节点都需要进行下面的验证。
c
在node03
docker pull nginx
docker pull tomcat
docker images

打标签
docker history nginx:latest
c
docker tag nginx:latest node01/zzy/nginx:1.25.2
docker images

- 登录
c
docker login node01

- 推送
c
docker push node01/zzy/nginx:1.25.2