项目容器化改造(三)企业级私有仓库Harbor部署
Docker engine安装
移除旧版本的Docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
安装最新版本
sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2
sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce
启动Docker
sudo systemctl start docker
设置开机启动
systemctl daemon-reload
systemctl restart docker
测试是否安装成功
docker run hello-world
参考:https://docs.docker.com/install/linux/docker-ce/centos/
Docker Compose安装
安装最新版
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
设置权限
sudo chmod +x /usr/local/bin/docker-compose
测试是否安装成功
docker-compose --version
安装Harbor
获取包地址
版本包地址:https://github.com/goharbor/harbor/releases
下载
wget https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-online-installer-v1.7.1.tgz
解压
tar -zxvf harbor-online-installer-v1.7.1.tgz
修改配置
vim harbor.cfg
修改hostname,改为机子的ip
安装
./install.sh
测试是否安装成功
访问主机ip,跳转此页面即为安装成功
推送、拉取镜像
配置http协议的仓库
Docker默认仓库地址是https协议,但harbor仓库默认是http协议。如果需要使用http协议的仓库,那么需要在docker的/etc/docker/daemon.json配置文件里面做如下设置:
{
"registry-mirrors": ["https://th3wopsw.mirror.aliyuncs.com"],
"insecure-registries": ["192.168.92.139"]
}
登录
输入账号、密码
docker login 192.168.92.139
打Tag
就用我们之前的hello-world镜像做测试
docker tag hello-world 192.168.92.139/library/hello-world
推送
docker push 192.168.92.139/library/hello-world
拉取
可以点击进入镜像仓库,复制出拉取语句,执行
docker pull 192.168.92.139/library/hello-world:latest