Docker私有仓库Harbor建立!
Posted handsomeboy-东
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker私有仓库Harbor建立!相关的知识,希望对你有一定的参考价值。
harbor简述
Harbor为存放镜像的私有仓库,可以部署在任何支持Docker的Linux发行版本上,它的核心组件是registry,它支持多种功能,图形化界面管理、多用户权限、角色管理机制、安全机制等
Harbor安装部署
安装docker
[root@harbor opt]# yum install -y yum-utils device-mapper-persistent-data lvm2
[root@harbor opt]# cd /etc/yum.repos.d/
[root@harbor yum.repos.d]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@harbor yum.repos.d]# yum install -y docker-ce
[root@harbor yum.repos.d]# mkdir /etc/docker
[root@harbor yum.repos.d]# vim /etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"insecure-registries": [
"192.168.118.44" ##存放harbor仓库服务器地址
],
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
~
[root@harbor yum.repos.d]# systemctl start docker
[root@harbor yum.repos.d]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@harbor yum.repos.d]# echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
[root@harbor yum.repos.d]# systemctl restart network
[root@harbor yum.repos.d]# systemctl restart docker
安装docker-compose
[root@harbor yum.repos.d]# curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
[root@harbor yum.repos.d]# chmod 755 -R /usr/local/bin/docker-compose
[root@harbor yum.repos.d]# docker-compose -v
docker-compose version 1.25.1, build a82fef07
安装harbor
[root@harbor opt]# tar xzf harbor-offline-installer-v1.9.3.tgz
[root@harbor opt]# vim ./harbor/harbor.yml
hostname: 192.168.118.44 ##更改部署harbor服务器的IP地址
[root@harbor opt]# cd ./harbor/
[root@harbor harbor]# ls
harbor.v1.9.3.tar.gz harbor.yml install.sh LICENSE prepare
[root@harbor harbor]# nohup ./install.sh &
- 访问192.168.118.44
- 新建项目
- 推送镜像到harbor仓库
[root@harbor harbor]# docker pull nginx
[root@harbor harbor]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest ad4c705f24d3 2 days ago 133MB
[root@harbor harbor]# docker tag ad4c705f24d3 192.168.118.44/whd/nginx-01 ##打标签
[root@harbor harbor]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.118.44/whd/nginx-01 latest ad4c705f24d3 2 days ago 133MB
nginx latest ad4c705f24d3 2 days ago 133MB
[root@harbor harbor]# docker login -u admin -p Harbor12345 http://192.168.118.44 ##登录harbor仓库
##登录过程如果出现https加密报错,在/usr/lib/systemd/system/docker.service文件中的ExecStart=/usr/bin/dockerd那里fd://后面添加--insecure-registry 192.168.118.44即可
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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
[root@harbor harbor]# docker push 192.168.118.44/whd/nginx-01 #上传镜像
Using default tag: latest
The push refers to repository [192.168.118.44/whd/nginx-01]
fac15b2caa0c: Pushed
f8bf5746ac5a: Pushed
d11eedadbd34: Pushed
797e583d8c50: Pushed
bf9ce92e8516: Pushed
d000633a5681: Pushed
latest: digest: sha256:6fe11397c34b973f3c957f0da22b09b7f11a4802e1db47aef54c29e2813cc125 size: 1570
- 刷新harbor网页查看
以上是关于Docker私有仓库Harbor建立!的主要内容,如果未能解决你的问题,请参考以下文章
Docker------搭建本地私有仓库及Horbor私有仓库