Harbor是VMWare开发的一个私有Docker-hub服务软件,依赖于docker registry服务,现在已开源(https://github.com/vmware/harbor)。这里介绍Harbor的搭建和简要使用方法。
搭建起来很简单(由于需要下载好几个基础镜像,花的时间比较长,不要着急):
# Harbor like a private docker-hub.
# Harbor is a registry manager for docker.
echo “Install harbor of docker on Ubuntu.”
echo “by openthings@163.com”
git clone https://github.com/vmware/harbor
cd harbor
cd Deploy
./prepare
sudo docker-compose up
echo “Please visit https://github.com/vmware/harbor”
如果机器上已经运行其他的Web服务,为了避免端口冲突,可以进去修改nginx的80端口。
vim /Deploy/docker-compose.yaml
进浏览器IP:端口号(缺省80),图形界面,按照提示操作即可。
命令行下,Docker镜像的上传/下载使用如下(以jenkins为例):
# 1、给镜像打标签将它指向你的registry
docker tag 1e6ed717014b localhost:5000/myrepo/jenkins
# 其中1e6ed717014b 是镜像id
# 2、Push镜像到registry
docker push localhost:5000/myrepo/jenkins
# 3、从registry Pull镜像
docker pull localhost:5000/myrepo/jenkins
运行时出现443:refused错误,首先修改docker-compose.yaml的enginx参数,加入443端口。然后,进去修改/etc/default/docker的参数,加入OPTIONS='--selinux-enabled --ipv6=false --insecure-registry=172.17.1.31:5001'类似的参数,如下:
# Docker Upstart and SysVinit configuration file
#
# THIS FILE DOES NOT APPLY TO SYSTEMD
#
# Please see the documentation for "systemd drop-ins":
# https://docs.docker.com/engine/articles/systemd/
#
# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"
# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
OPTIONS='--selinux-enabled --ipv6=false --insecure-registry=172.17.1.31:5001'
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"
# This is also a handy place to tweak where Docker's temporary files go.
#export TMPDIR="/mnt/bigdrive/docker-tmp"