搭建私有docker库harbor

本示例均在centos7上操作

1.安装docker

yum update

yum install docker

 

2.安装docker-compose

curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

3.下载harbor

1.下载
wget https://github.com/vmware/harbor/releases/download/0.5.0/harbor-offline-installer-0.5.0.tgz

2.解压
tar zxvf harbor-offline-installer-0.5.0.tgz

3.修改配置
cd harbor/
vim harbor.cfg

harbor

 

我的80端口已经被占用了,所以nginx指向不能为80和443所以需要修改,如果你的没被占用这一段不需要修改

#vim docker-compose.yml

proxy:
    image: nginx:1.11.5
    container_name: nginx
    restart: always
    volumes:
      - ./common/config/nginx:/etc/nginx
    ports:
      - 8080:80
      - 1443:443
    depends_on:
      - mysql
      - registry
      - ui
      - log

#vim common/templates/registry/config.yml

auth:
  token:
    issuer: registry-token-issuer
    realm: $ui_url:8080/service/token
    rootcertbundle: /etc/registry/root.crt
    service: token-service

 

 

3.初始化

/usr/local/harbor/install.sh

执行完后可以执行docker ps查看

# docker ps            
CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS              PORTS                                                              NAMES
e6da3450bebe        vmware/harbor-jobservice:v1.2.0    "/harbor/harbor_jo..."   4 days ago          Up 4 days                                                                              harbor-jobservice
6134227d7ed4        vmware/nginx-photon:1.11.13        "nginx -g 'daemon ..."   4 days ago          Up 4 days           0.0.0.0:8080->80/tcp, 0.0.0.0:1443->443/tcp, 0.0.0.0:4443->4443/tcp   nginx
ef5fe0b856a7        vmware/harbor-ui:v1.2.0            "/harbor/harbor_ui"      4 days ago          Up 4 days                                                                              harbor-ui
a752861c7e92        vmware/registry:2.6.2-photon       "/entrypoint.sh se..."   4 days ago          Up 4 days           5000/tcp                                                           registry
78ea91838582        vmware/harbor-db:v1.2.0            "docker-entrypoint..."   4 days ago          Up 4 days           3306/tcp                                                           harbor-db
024e226ff135        vmware/harbor-adminserver:v1.2.0   "/harbor/harbor_ad..."   4 days ago          Up 4 days                                                                              harbor-adminserver
3fab80444a1d        vmware/harbor-log:v1.2.0           "/bin/sh -c 'crond..."   4 days ago          Up 4 days           127.0.0.1:1514->514/tcp                                            harbor-log

 

在浏览器输入docker.yonfon.com,因为我配置的域名为docker.yonfon.com。请大家根据自己的配置情况输入访问的域名;
默认账号:admin 密码:Harbor12345 登录后修改密码

 

4.测试上传

vim /etc/docker/daemon.json
{ "insecure-registries":["docker.yonfon.com"] }

增加注册地址,这样登录时不会报htts错误
重启docker
systemctl  restart docker


拉取镜像
docker pull busybox
创建标签
docker tag busybox:latest docker.yonfon.com/library/busybox:latest
推送
docker push docker.yonfon.com/library/busybox:latest

转载请注明原文链接:搭建私有docker库harbor

发表评论:

共有 0 条评论

 Top