Docker本地私有倉庫的創建

環境:docker

192.168.139.26 docker的客戶端ubuntu

192.168.139.52 docker的服務器端(倉庫所在位置)服務器


首先在192.168.139.52上下載registry鏡像tcp

zxl@zxl-ubuntu:~$ sudo docker pull registryide


下面操做在192.168.139.52完成spa


默認狀況下會將倉庫存放於容器內的/tmp/registry目錄下,這樣若是容器被刪除,則存放於容器中的鏡像也會丟失,因此咱們通常狀況下會指定本地一個目錄掛載到容器內的/tmp/registry下,並用registry鏡像建立建立並啓動一個容器,以下:3d

zxl@zxl-ubuntu:~$ sudo docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registryit

6bd275a34ad9130aeb146d8761f6002a512df48308e6836655abea0754322e0aclass


下面操做在192.168.139.26完成test

zxl@zxl-ubuntu:~$ sudo docker ps #查看本機當前運行的容器,只有registry容器

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES

6bd275a34ad9        registry            "/entrypoint.sh /e..."   22 seconds ago      Up 19 seconds       0.0.0.0:5000->5000/tcp   distracted_almeida


zxl@Ubuntu:~$ docker p_w_picpaths

REPOSITORY                                TAG                 IMAGE ID            CREATED             SIZE

my-ubuntu                                 latest              14f60031763d        11 days ago         120MB


zxl@Ubuntu:~$ sudo docker tag my-ubuntu:latest 192.168.139.52:5000/u_bantu


zxl@Ubuntu:~$ docker p_w_picpaths

REPOSITORY                                TAG                 IMAGE ID            CREATED             SIZE

192.168.139.52:5000/u_bantu               latest              14f60031763d        11 days ago         120MB

my-ubuntu                                 latest              14f60031763d        11 days ago         120MB


zxl@Ubuntu:~$ sudo docker  push 192.168.139.52:5000/u_bantu

The push refers to a repository [192.168.139.52:5000/u_bantu]

26b126eb8632: Pushed 

220d34b5f6c9: Pushed 

8a5132998025: Pushed 

aca233ed29c3: Pushed 

e5d2f035d7a4: Pushed 

latest: digest: sha256:84c334414e2bfdcae99509a6add166bbb4fa4041dc3fa6af08046a66fed3005f size: 1357

將兩個鏡像所有刪除

zxl@Ubuntu:~$ sudo docker rmi my-ubuntu

zxl@Ubuntu:~$ sudo docker rmi  14f60031763d

從192.169.139.52服務器(本地私有倉庫上從新下載)

zxl@Ubuntu:~$ docker pull 192.168.139.52:5000/u_bantu

Using default tag: latest

latest: Pulling from u_bantu

e0a742c2abfd: Pull complete 

486cb8339a27: Pull complete 

dc6f0d824617: Pull complete 

4f7a5649a30e: Pull complete 

672363445ad2: Pull complete 

Digest: sha256:84c334414e2bfdcae99509a6add166bbb4fa4041dc3fa6af08046a66fed3005f

Status: Downloaded newer p_w_picpath for 192.168.139.52:5000/u_bantu:latest

能夠看到直接從192.169.139.52服務器(本地私有倉庫)下載成功

zxl@Ubuntu:~$ docker p_w_picpaths

REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE

192.168.139.52:5000/u_bantu   latest              14f60031763d        11 days ago         120MB


下面操做在192.169.139.52完成

在192.169.139.52上能夠看到沒有192.168.139.52:5000/u_bantu 鏡像

zxl@zxl-ubuntu:~$ sudo docker p_w_picpaths

REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE

registry                      latest              751f286bc25e        11 days ago         33.2MB

直接從192.169.139.52服務器(本機)下載

zxl@zxl-ubuntu:~$ sudo docker pull 192.168.139.52:5000/u_bantu

Using default tag: latest

latest: Pulling from u_bantu

e0a742c2abfd: Pull complete 

486cb8339a27: Pull complete 

dc6f0d824617: Pull complete 

4f7a5649a30e: Pull complete 

672363445ad2: Pull complete 

Digest: sha256:84c334414e2bfdcae99509a6add166bbb4fa4041dc3fa6af08046a66fed3005f

Status: Downloaded newer p_w_picpath for 192.168.139.52:5000/u_bantu:latest

能夠看到下載成功

zxl@zxl-ubuntu:~$ sudo docker p_w_picpaths

REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE

registry                      latest              751f286bc25e        11 days ago         33.2MB

192.168.139.52:5000/u_bantu   latest              14f60031763d        11 days ago         120MB


這樣在192.168.139.52服務器上建立本地私有倉庫成功,只要能夠訪問192.168.139.52:5000端口的主機均可以直接在此倉庫下載此倉庫已經有的鏡像

相關文章
相關標籤/搜索