Docker倉庫搭建(Registry + Portus)

1.更新系統:html

    yum update -ypython

2. 安裝docker-composgit

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

3.安裝git客戶端web

  yum install -y gitdocker

4.複製Portus安裝程序centos

  git clone https://github.com/SUSE/Portus.git服務器

5.配置Docker安裝源網絡

  vi /etc/yum.repos.d/docker.repo
    [dockerrepo]
     name=Docker Repository
    baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
    enabled=1
    gpgcheck=1
    gpgkey=
    https://yum.dockerproject.org/gpg
tcp

6.安裝docker引擎並啓動

   yum cleal all && yum makecache
  yum install -y docker-engine
  systemctl start docker.service
  systemctl enable docker.service

此步若是有保存,請參考下面連接的地址:

http://www.cnblogs.com/amoyzhu/p/5261393.html

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
./compose-setup.sh -e 192.168.0.109
#安裝過程當中會下載registry、mariadb、rails、ports_web等幾個docker鏡像
#若是網絡很差能夠先下載對應的幾個docker鏡像文件
#而後上傳到portus服務器上並用docker load命令加載。
#鏡像的具體版本號以實際爲準。
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
portus_web          latest              24a654206d8b        2 days ago          1.086 GB
registry            2.3.1               83139345d017        4 months ago        165.8 MB
mariadb             10.0.23             93631b528e67        5 months ago        304.6 MB
rails               4.2.2               99b347e4bbb4        13 months ago       884.5 MB
安裝事後會給出相應的登錄信息和客戶端須要的操做樣例
###################
#     SUCCESS     #
###################

Make sure port 3000 and 5000 are open on host 192.168.0.109

Open http://192.168.0.109: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 192.168.0.109: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 192.168.0.109:5000'
  - Perform the docker login.

To authenticate against your registry using the docker cli do:

  $ docker login -u <portus username> -p <password> -e <email> 192.168.0.109:5000

To push an image to the private registry:

  $ docker pull busybox
  $ docker tag busybox 192.168.0.109:5000/<username>busybox
  $ docker push 192.168.0.109:5000/<username>busybox



八、打開防火牆端口

 

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



9. Portus初始化


 
鏈接到本docker倉庫(也能夠是其餘倉庫,必須是registry 2.0以上版本)
<ignore_js_op> 
十、上傳鏡像測試
修改文件/lib/systemd/system/docker.service中的ExecStart增長--insecure-registry 192.168.0.109:5000並重啓docker服務

1
2
systemctl daemon-reload
systemctl restart docker.service



檢查docker服務

 

1
2
# ps -ef|grep insecure-registry
root     29486     1  0 01:32 ?        00:00:00 /usr/bin/dockerd --insecure-registry 192.168.0.109:5000

11. 重啓Portus容器:

docker start portus_db_1 portus_web_1 portus_crono_1 portus_registry_1

12.下載busybox鏡像並上傳到私有的倉庫中(安裝結束時有操做提示)

docker pull busybox

從docker官網上下載busybox鏡像到本地


docker tag busybox 192.168.0.109:5000/admin/busybox

把剛下載的鏡像busybox打上tag(重命名):192.168.0.109:5000/admin/busybox


docker login -u admin -p admin123 192.168.0.109:5000

登錄私有的鏡像倉庫


docker push 192.168.0.109:5000/admin/busybox

把本地的tag爲192.168.0.109:5000/admin/busybox上傳到私有倉庫。



檢查Portus界面的鏡像信息
 

13.下載鏡像測試

    docker pull 192.168.0.109:5000/admin/busybox

相關文章
相關標籤/搜索