62

Centos 7.4 搭建Docker私有镜像库Harbor

 5 years ago
source link: http://dockone.io/article/6179?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

玩docker,image们无处安放,头疼+捉急。。。于是决定在虚拟机上,

用Harbor搭建一个私有镜像库,说干就干 :)

1. 准备工作

软件名 版本号

linux Centos7.4

docker 18.03.1-ce

docker-compose 1.21.2

python 2.7

准备工作的步骤省略,如有问题请上网搜索 :)

2. 安装Harbor

1)从Github上,下载Harbor并解压。

miaeY3M.png!web

2)修改 harbor.cfg配置文件。

2mUr2u6.png!web

3)在harbor.cfg同级目录下按顺序执行

./prepare

./install.sh

bUneeyz.png!web

Harbor正常启动的提示信息,如下图。

fEfemma.png!web

OK, 再看下Web端,是这个样子滴,就表示没问题。

(默认的登录名密码是:admin/Harbor12345)

7b2MN3n.png!web

到此为止,私有库搭建完毕,测试一下呗。

3. 登录私有库

1)找一台虚拟机,docker login登录私有库。

iQbeUrv.png!web

2)拿busybox举个栗子,打个tag。

ABfique.png!web

3uYRVfz.png!web

4. 上传镜像

用docker push 命令上传至harbor私有库。

YRbyi2E.png!web

总是不放心,还得来Web端看看。。。

zIJVNrQ.png!web

5. 下载镜像

7F7zimb.png!web

6. 注意点

本次配置文件中的hostname不是域名,而是服务器ip,需要在docker的配置文件中添加–insecure-registry server_ip的参数,否则会报如下错误。

IfMZFbj.png!web

这次的centos7.4中,找了半天居然没有找见docker的配置文件,最后手动创建了一个/etc/sysconfig/docker。。。

/etc/sysconfig/docker# Modify these options if you want to change the way the docker daemon runs

OPTIONS='-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock'

OPTIONS=" --insecure-registry 192.168.198.XX"

DOCKER_CERT_PATH=/etc/docker

If you want to add your own registry to be used for docker search and docker

pull use the ADD_REGISTRY option to list a set of registries, each prepended

with --add-registry flag. The first registry added will be the first registry

searched.

ADD_REGISTRY='--add-registry registry.access.redhat.com'

If you want to block registries from being used, uncomment the BLOCK_REGISTRY

option and give it a set of registries, each prepended with --block-registry

flag. For example adding docker.io will stop users from downloading images

from docker.io

BLOCK_REGISTRY='--block-registry'

If you have a registry secured with https but do not have proper certs

distributed, you can tell docker to not look for full authorization by

adding the registry to the INSECURE_REGISTRY line and uncommenting it.

INSECURE_REGISTRY='--insecure-registry dl.dockerpool.com:5000'

On an SELinux system, if you remove the --selinux-enabled option, you

also need to turn on the docker_transition_unconfined boolean.

setsebool -P docker_transition_unconfined 1

Location used for temporary files, such as those created by

docker load and build operations. Default is /var/lib/docker/tmp

Can be overriden by setting the following environment variable.

DOCKER_TMPDIR=/var/tmp

Controls the /etc/cron.daily/docker-logrotate cron job status.

To disable, uncomment the line below.

LOGROTATE=false

创建完了配置文件,一定要执行下面两个命令。

systemctl daemon-reload

systemctl restart docker

结果如下,祝各位玩的开心~

3umiQfM.png!web


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK