首頁 >運維 >Docker >docker怎麼在本地建倉庫

docker怎麼在本地建倉庫

WJ
WJ原創
2020-06-08 17:00:062914瀏覽

docker怎麼在本地建倉庫

docker怎麼在本地建倉庫?

1.安裝docker

yum install docker -y

之後根據需求把指定docker安裝目錄,或是新建一個磁碟使用docker-storage-setup來使用

2.設定第三方docker映像來做加速

vim /etc/docker/daemon.json
{"registry-mirrors": ["http://hub-mirror.c.163.com",{"insecure-registries":["registry:5000"]}]
}

#3.安裝docker本機倉庫

systemctl start docker
docker pull docker.io/registry
docker images

4.啟動本地倉庫

docker run -d --name=registry -p 5000:5000 docker.io/registry

5.上傳鏡像到倉庫

docker tag docker.io/registry registry:5000/resistry:v1
docker push registry:5000/resistry:v1

6.登陸到registry查看上傳的內容


### #
docker exec -it registry sh
/ # ls /var/lib/registry/docker/registry/v2/repositories/resistry
######7.查看倉庫的images目錄######
[root@localhost ~]# curl http://registry:5000/v2/_catalog  #目录{"repositories":["centos","resistry"]}
[root@localhost ~]# curl http://registry:5000/v2/centos/tags/list  #image的版本信息{"name":"centos","tags":["6.9","6"]}
[root@localhost ~]# curl http://registry:5000/v2/image_name/tags/list{"errors":[{"code":"NAME_UNKNOWN","message":"repository name not known to registry","detail":{"name":"image_name"}}]}
[root@localhost ~]#
#######8.其他伺服器從registry來取得鏡像,追加以下資訊######
vim /etc/docker/daemon.json
{
{"insecure-registries":["registry:5000"]}
}
## #9.取得images###
docker pull registry:5000/centos:6.9docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
registry:5000/centos   6.9                 2199b8eb8390        11 months ago       195 MB
###相關推薦:######docker教學############

以上是docker怎麼在本地建倉庫的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn