部署Harbor仓库

本章内容:

  • 安装docker-ce
  • 部署harbor仓库
  • 上传和拉取

1.安装docker

1)拉取源码 
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
2)安装docker-ce
yum -y install docker-ce
3)查看docker版本
docker -v
4)创建docker-compose软连接
find / -name docker-compose
ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin
5)配置镜像加速器并启动docker
  sudo mkdir -p /etc/docker
  sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://6kivj4sd.mirror.aliyuncs.com"]
}
EOF

 sudo systemctl daemon-reload
 sudo systemctl restart docker
 systemctl status docker

2.部署harbor仓库

1)拉取软件包
wget https://github.com/goharbor/harbor/releases/download/v2.10.3/harbor-offline-installer-v2.10.3.tgz
2)解压软件包
tar zxvf harbor-offline-installer-v2.10.3.tgz
3)进入harbor目录,修改配置文件名
cd harbor        \\进入解压harbor目录
mv harbor.yml.tmpl harbor.yml    \\修改一下配置文件名
4)修改配置文件
  1 # Configuration file of Harbor
  2 
  3 # The IP address or hostname to access admin UI and registry service.
  4 # DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed     by external clients.
  5 hostname: 192.168.182.202        \\修改为主机IP地址
  6 
  7 # http related config
  8 http:
  9   # port for http, default is 80. If https enabled, this port will redire    ct to https port
 10   port: 80        \\端口号可以自定义修改
 11 
 12 # https related config    \\这里注释https 需要开启的话自行开启
 13 #https:
 14   # https port for harbor, default is 443    
 15  # port: 443
 16   # The path of cert and key files for nginx
 17  # certificate: /your/certificate/path
 18  # private_key: /your/private/key/path
 19   # enable strong ssl ciphers (default: false)
 20   # strong_ssl_ciphers: false
 21 
5)安装harbor仓库
./install.sh
6)登录名为admin,密码是Harbor12345

7)登录harbor仓库

3.拉取镜像和上传镜像

1)准备另外一台机器,下载docker 这里不再演示上面有下载演示
2)创建拉取镜像的地址文件(IP地址指定仓库)
cat /etc/docker/daemon.json 
{
	"insecure-registries": ["http://192.168.182.202:80"]
}
3)登录

4)打标签
[root@node03 ~]# docker images    //列出所有镜像 这里提前拉取的httpd镜像
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
httpd        latest    dabbfbe0c57b   2 years ago   144MB
[root@node03 ~]# docker tag dabbfbe0c57b 192.168.182.202:80/test/web01:v1    //把httpd镜像打上标签
5)推送镜像到harbor仓库
docker push 192.168.182.202:80/test/web01:v1

进入仓库查看是否推送成功

6)拉取镜像命令
[root@node03 ~]# docker pull 192.168.182.202/test/web01:v1    //拉取镜像失败因为这里没有用https证书所以需要指定http的80端口号
Error response from daemon: Get "https://192.168.182.202/v2/": dial tcp 192.168.182.202:443: connect: connection refused
[root@node03 ~]# docker pull 192.168.182.202:80/test/web01:v1    //指定端口号后拉取镜像
v1: Pulling from test/web01
a2abf6c4d29d: Already exists 
dcc4698797c8: Already exists 
41c22baa66ec: Already exists 
67283bbdd4a0: Already exists 
d982c879c57e: Already exists 
Digest: sha256:57c1e4ff150e2782a25c8cebb80b574f81f06b74944caf972f27e21b76074194
Status: Downloaded newer image for 192.168.182.202:80/test/web01:v1
192.168.182.202:80/test/web01:v1
[root@node03 ~]# 
[root@node03 ~]# 
[root@node03 ~]# 
[root@node03 ~]# docker images    //查看是否拉取成功
REPOSITORY                      TAG       IMAGE ID       CREATED       SIZE
<none>                          <none>    cbb418be655d   5 hours ago   148MB
192.168.182.202:80/test/web01   v1        dabbfbe0c57b   2 years ago   144MB
[root@node03 ~]# 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值