Portus管理Docker的Registry仓库

系统版本: CentOS Linux release 7.2.1511 (Core)

step 1: 更新系统

yum update -y

step 2: 安装docker-compose

yum -y install epel-release #pip安装包在epel源中
yum -y install python-pip
pip install -U docker-compose

step 3: 安装git客户端

yum install -y git

step 4:复制Portus安装程序

git clone https://github.com/SUSE/Portus.git

step 5:配置Docker安装源

1
2
3
4
5
6
7
[root@ct7 ~]# more /etc/yum.repos.d/docker.repo
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

step 6:安装docker引擎并启动

1
2
3
4
yum cleal all && yum makecache
yum install -y docker-engine
systemctl start docker.service
systemctl enable docker.service

step 7:安装Portus

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
./compose-setup.sh -e 192.168.0.109
Step 11 : ADD . .
---> 08d874cfd4fa
Removing intermediate container 0062e29a08fb
Successfully built 08d874cfd4fa
WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating portus_db_1
Creating portus_web_1
Creating portus_crono_1
Creating portus_registry_1
Waiting for mariadb to be ready in 5 seconds
Portus: configuring database... [SUCCESS]
###################
# SUCCESS #
###################
Make sure port 3000 and 5000 are open on host 0.0.0.50
Open http://0.0.0.50:3000 with your browser and perform the following steps:
1. Create an admin account
2. You will be redirected to a page where you have to register the registry. In this form:
- Choose a custom name for the registry.
- Enter 0.0.0.50:5000 as the hostname.
- Do *not* check the "Use SSL" checkbox, since this setup is not using SSL.
Perform the following actions on the docker hosts that need to interact with your registry:
- Ensure the docker daemon is started with the '--insecure-registry 0.0.0.50:5000'
- Perform the docker login.
To authenticate against your registry using the docker cli do:
$ docker login -u <portus username> -p <password> -e <email> 0.0.0.50:5000
To push an image to the private registry:
$ docker pull busybox
$ docker tag busybox 0.0.0.50:5000/<username>/busybox
$ docker push 0.0.0.50:5000/<username>/busybox
###################
# Issue1 #
###################
以上是安装成功的,由于网络的原因,我们在download phantomjs_1.9.0-1_amd64.deb 发生了 timeout, 所以需要手工的下载好了之后在安装,在文件添加如下命令
cd /var/cache/apt/archives && \
wget http://download.opensuse.org/repositories/home:/flavio_castelli:/phantomjs/Debian_8.0/./amd64/phantomjs_1.9.0-1_amd64.deb && \
apt-get install -y --no-install-recommends phantomjs nodejs apt-utils && \
[root@ct7 Portus]# more /home/tony/Portu/Portus/Dockerfile
FROM library/ruby:2.3.1
MAINTAINER Flavio Castelli <fcastelli@suse.com>
ENV COMPOSE=1
EXPOSE 3000
WORKDIR /portus
COPY Gemfile* ./
RUN bundle install --retry=3
# Install phantomjs, this is required for testing and development purposes
# There are no official deb packages for it, hence we built it inside of the
# open build service.
RUN echo "deb http://download.opensuse.org/repositories/home:/flavio_castelli:/phantomjs/Debian_8.0/ ./" >> /etc/apt/sources.list
RUN wget http://download.opensuse.org/repositories/home:/flavio_castelli:/phantomjs/Debian_8.0/Release.key && \
apt-key add Release.key && \
rm Release.key
RUN apt-get update && \
cd /var/cache/apt/archives && \
wget http://download.opensuse.org/repositories/home:/flavio_castelli:/phantomjs/Debian_8.0/./amd64/phantomjs_1.9.0-1_amd64.deb && \
apt-get install -y --no-install-recommends phantomjs nodejs apt-utils && \
rm -rf /var/lib/apt/lists/*
ADD . .
###################
# Issue2 #
###################
创建完,并且docker push 到registry上,访问URL:http://0.0.0.50:3000/,发现没有任何的数据,这个因为防火墙的原因,具体操作看下一步

step 8:打开防火墙端口

1
2
3
firewall-cmd --zone=public --add-port=3000/tcp --permanent
firewall-cmd --zone=public --add-port=5000/tcp --permanent
systemctl restart firewall.service

step 9:Portus初始化配置

在浏览器中打开创建默认管理员用户
此处输入图片的描述

连接到本docker仓库(也可以是其他仓库,必须是registry 2.0以上版本)(不要选择SSL,创建失败会提示 remote check disable 就可以)
此处输入图片的描述

step 10:在docker client上传镜像到docker registry

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
创建/etc/docker/daemon.json文件,并写入
[root@ct7 system]# more /etc/docker/daemon.json
{ "insecure-registries":["0.0.0.50:5000"] }
然后重启docker:
[root@ct7 system]# systemctl daemon-reload
[root@ct7 system]# service docker restart
[root@ct7 system]# docker login -u admin -p P@ss1234 -e admin@hz-zabbix.qa.webex.com 0.0.0.50:5000
Flag --email has been deprecated, will be removed in 1.13.
Login Succeeded
[root@ct7 system]# docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
56bec22e3559: Pull complete
Digest: sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912
Status: Downloaded newer image for busybox:latest
[root@ct7 system]# docker tag busybox 0.0.0.50:5000/admin/busybox
[root@ct7 system]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
0.0.0.50:5000/admin/busybox latest e02e811dd08f 3 weeks ago 1.093 MB
busybox latest e02e811dd08f 3 weeks ago 1.093 MB
[root@ct7 system]# docker push 0.0.0.50:5000/admin/busybox
The push refers to a repository [0.0.0.50:5000/admin/busybox]
e88b3f82283b: Pushed
latest: digest: sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912 size: 527

step 11.检查Portus界面的镜像信息

此处输入图片的描述

step 12.重启Portus应用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@ct7 Portus]# pwd
/home/tony/Portu/Portus
[root@ct7 Portus]# docker-compose stop
Stopping portus_registry_1 ... done
Stopping portus_web_1 ... done
Stopping portus_crono_1 ... done
Stopping portus_db_1 ... done
[root@ct7 Portus]# docker-compose up
Starting portus_db_1
Starting portus_web_1
Starting portus_crono_1
Starting portus_registry_1

select extract(year from date ‘2016-11-1’) year,
extract(month from date ‘2016-11-1’) month,
extract(day from date ‘2016-11-1’) day
from dual;

SYSDATE DATE1 DATE_YEAR DATE_MONTH DATE_NUM


2016-11-02 01:22:24 2016-11-02 01:22:24 twenty sixteen-11-02 01:22:24 16-november -02 01:22:24 16-11-02 WED 01:22:24

SYSDATE DATE1 DATE_YEAR DATE_MONTH DATE_NUM DATE_FM


2016-11-02 01:27:05 2016-11-02 01:27:05 twenty sixteen-11-02 01:27:05 16-november -02 01:27:05 16-11-02 WED 01:27:05 16-11-2 WED 1:27:5