ubuntu下部署帶認證的私人docker registry(原創請註明出處)

來源:互聯網
上載者:User
author: zqh
date: 2016-5-11
介紹

Docker倉庫實際上提供兩方面的功能,一個是鏡像管理,一個是認證。前者主要由docker-registry項目來實現,通過http服務來上傳下載;後者可以通過docker-index(閉源)項目或者利用現成認證方案(如nginx)實現http要求管理。 環境

實體機

機房openstack伺服器

宿主機 以ubuntu vivid 15.04鏡像建立的虛擬機器 網路 能串連到公網 dns 10.68.7.142上的dnsmasq 許可權 有root許可權或者可以執行sudo 基本結構

前端使用nginx的https協議進行basic authentication;nginx使用http協議代理docker registry的5000連接埠。
安裝docker 更新系統
>>> apt-get update && apt-get upgrade -y>>> reboot
安裝docker 檢查curl包
>>> which curl
安裝curl包(已安裝跳過此步驟)
>>> apt-get install curl
安裝docker
>>> curl -sSL https://get.docker.com/ | sh

Note

https://get.docker.com/內容為一個安裝指令碼,如果失敗多試幾次。 測試 docker

>>> docker version #查看版本Client:Version:      1.9.1API version:  1.21Go version:   go1.4.2Git commit:   a34a1d5Built:        Fri Nov 20 13:16:54 UTC 2015OS/Arch:      linux/amd64Server:Version:      1.9.1API version:  1.21Go version:   go1.4.2Git commit:   a34a1d5Built:        Fri Nov 20 13:16:54 UTC 2015OS/Arch:      linux/amd64
>>> docker pull hello-world #下載鏡像測試Using default tag: latestlatest: Pulling from library/hello-world79112a2b2613: Pull complete4c4abd6d4278: Pull completeDigest: sha256:4f32210e234b4ad5cac92efacc0a3d602b02476c754f13d517e1ada048e5a8baStatus: Downloaded newer image for hello-world:latest
啟動docker registry服務 下載registry鏡像
>>> docker pull registry:22: Pulling from library/registry3059b4820522: Pull completeff978d850939: Pull complete5a85aa5e7c2b: Pull complete8c597b986e48: Pull completeebf4ce6dfdd0: Pull completec45dd354ad24: Pull completebfc3f550ff55: Pull complete279b06747fae: Pull complete06552075e36c: Pull completeDigest: sha256:f8cd74689f55009ad08359688c61054099cc28c90ecc7eaceb83ada0bb69ca75Status: Downloaded newer image for registry:2
啟動docker registry
>>> docker run -idt -v /opt/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry egistry:2e60079ce80f9170c46cc1df722e2ef47eeb0395da7123d693c54a82ecd5b1253
i: 保持sdtin開放狀態
d: 使容器以守護進程方式後台運行,並列印容器id
t: 分配一個tty(虛擬終端裝置)
v: 綁定掛載一個容器內的路徑到宿主機路徑
p: 映射一個容器的連接埠到宿主機連接埠
restart: 當容器退出時的重啟策略
name: 給容器命名一個名稱
查看docker registry進程
>>> docker psCONTAINER ID IMAGE      COMMAND                CREATED        STATUS        PORTS                  NAMESe60079ce80f9 registry:2 "/bin/registry serve " 57 seconds ago Up 56 seconds 0.0.0.0:5000->5000/tcp registry
驗證可用性 打tag
>>> docker tag hello-world 127.0.0.1:5000/hello-world #給hello-world鏡像打tag
查看本地鏡像
>>> docker imagesREPOSITORY                   TAG        IMAGE ID         CREATED         VIRTUAL SIZEregistry                     2          06552075e36c     6 days ago      171.2 MBhello-world                  latest     4c4abd6d4278     2 weeks ago     967 B127.0.0.1:5000/hello-world   latest     4c4abd6d4278     2 weeks ago     967 B
push鏡像到私人倉庫
>>> docker push 127.0.0.1:5000/hello-worldThe push refers to a repository [127.0.0.1:5000/hello-world] (len: 1)4c4abd6d4278: Pushed79112a2b2613: Pushedlatest: digest: sha256:986c84e32ef73f64fb974588427dec5ff6ed699a8ac59c2414a2300c0d12528a size: 2740
查看宿主機映射目錄
>>> ll /opt/registry

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.