目录
1. 说明
2. 安装
1. 安装docker
2. 安装docker-compose
3. 安装Harbor
在 CentOS 7 环境下安装 docekr 及 harbor
# 安装yum工具集
yum install -y yum-utils
# 安装docker源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 更新yum缓存
yum makecache fast
# 安装docker
yum install -y docker-ce
# 启动docker
systemctl start docker
# 设置docker开机自启动
systemctl enable docker
# 验证
docker version
docker run hello-world
注1:运行“sudo docker run hello-world”时报错:docker: Error response from daemon
。解决方法:docker默认的源为国外官方源,下载速度较慢,可修改docker镜像源为国内:
[root@localhost]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com"]
}
重启docker:
systemctl restart docker
注2:非root用户解决运行docker命令时Get Permission Denied问题:
sudo groupadd docker #添加docker用户组
sudo gpasswd -a $USER docker #将登陆用户加入到docker用户组中
newgrp docker #更新用户组
docker ps #测试docker命令是否可以使用sudo正常使用
使用pip安装:
# 安装 EPEL 软件包
sudo yum install epel-release
# 安装pip
sudo yum install -y python-pip
# 升级pip
sudo pip install --upgrade pip
# 安装docker-compose
sudo pip install docker-compose
注:安装docker-compose时报错(sudo pip install docker-compose时)
ERROR: Cannot uninstall 'subprocess32'. It is a distutils installed project and thus we cannot accurately determine which >files belong to it which would lead to only a partial uninstall.
解决办法:
# 搜索subprocess32-3.2.6-py2.7.egg-info文件
sudo find / -name *subpro*.egg-info
# 删除
rm -rf /usr/lib64/python2.7/site-packages/subprocess32-3.2.6-py2.7.egg-info
ERROR: Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
解决办法:
# 搜索requests-2.6.0-py2.7.egg-info文件
sudo find / -name *requests*.egg-info
# 删除
rm -rf /usr/lib/python2.7/site-packages/requests-2.6.0-py2.7.egg-inf
然后重新安装:
sudo pip install docker-compose
下载并解压harbor安装包:
wget https://storage.googleapis.com/harbor-releases/harbor-offline-installer-v1.5.3.tgz
tar -zxvf harbor-offline-installer-v1.5.3.tgz #解压离线安装包
mv harbor /opt/ #移到/opt目录下
cd /opt/harbor #进入到/opt/harbor目录
ll #查看目录内容
编辑配置文件:
vim harbor.cfg #编辑配置文件
修改以下内容:
hostname = localhost #修改harbor的启动ip,这里需要依据系统ip设置
harbor_admin_password = admin #修改harbor的admin用户的密码
安装Harbor:
./prepare #配置Harbor
./install.sh #安装Harbor
登录harbor,以 admin 用户,密码 admin 登录系统,如下: