1、安装环境
服务器系统: openEuler
服务器架构:x86
192.168.199.149 私服
192.168.199.150 docker拉取镜像测试
docker版本:18.09.0
docker-compose版本:1.22.0
Habor版本:2.0.0
2、安装流程
2.1 安装docker和docker-compose
#下载docker
yum -y install docker
#输出版本信息
docker --version
#下载docker-compose
yum -y install docker-compose
#输出版本信息
docker-compose --version
2.2 安装Harbor
#下载地址
https://github.com/vmware/harbor/releases/download/v2.0.0/harbor-offline-installer-v2.0.0.tgz
#上传到服务器 解压安装包
tar -zxvf harbor-offline-installer-v2.0.0.tgz
#进入harbor目录 修改配置文件名称
cd harbor
mv harbor.yml.tmpl harbor.yml
#修改配置文件
vi harbor.yml
hostname: 192.168.199.149 #改为自己本机ip
# 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:
# https port for harbor, default is 443
#port: 443
# The path of cert and key files for nginx
#certificate: /your/certificate/path
#private_key: /your/private/key/path
#安装harbor
./install.sh
#关闭防火墙和开启禁用
systemctl stop firewalld && systemctl disable firewalld
2.3 验证成功
2.4 访问页面
用户:admin
密码:Harbor12345
3、镜像上传与拉取
3.1在另外一台服务器制作镜像 并上传到harbor私服
#docker需要配置镜像源
cat >> /etc/docker/daemon.json << EOF
{
"insecure-registries": ["http://192.168.199.149:80"]
}
EOF
#注意,不可省略http和80端口,不然就会推送失败
#重启
systemctl restart docker
出现下面配置成功
docker info
3.2 制作nginx镜像
#下载镜像
docker nginx
#标记镜像 采用下载的格式
docker tag SOURCE_IMAGE[:TAG] 192.168.199.149:80/library/REPOSITORY[:TAG]
#例如标记nginx
docker tag nginx:latest 192.168.199.149:80/library/nginx:1.0
3.3 推送制作nginx镜像
#登陆docker 输入harbor用户名和密码
docker login 192.168.199.149:80
#日志如下
[root@localhost ~]# docker login 192.168.199.149:80
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
docker logout
#上传nginx 1.0镜像
#格式
docker push 192.168.199.149:80/library/REPOSITORY[:TAG]
#例如 nginx
docker push 192.168.199.149:80/library/nginx:1.0
3.4 harbor查看上传镜像
3.5 拉取刚才上传的镜像
docker pull 192.168.199.149:80/library/nginx:1.0