阿裡雲個人加速位址
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
配置鏡像加速
針對Docker用戶端版本大于 1.10.0 的使用者
可以通過修改daemon配置檔案/etc/docker/daemon.json來使用加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://vvnjr2qb.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
其他加速源
- DockerProxy:https://dockerproxy.com;
- 網易源:https://hub-mirror.c.163.com;
- 百度源:https://mirror.baidubce.com;
- 騰訊源:https://ccr.ccs.tencentyun.com
# 編輯 Docker 配置檔案
$ sudo vim /etc/docker/daemon.json
# 加入以下配置項
{
"registry-mirrors": [
"https://dockerproxy.com",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://ccr.ccs.tencentyun.com"
]
}
鏡像制作與釋出
1、commit自己的鏡像(docker commit指令操作)
docker commit送出容器副本使之成為一個新的鏡像
docker commit -m="送出的描述資訊" -a="作者" 容器ID 要建立的目标鏡像名:[标簽名]
#例:
docker commit -m="添加vm" -a="作者" 7711bdd8b2dc szz/ubuntu:1.0
2、釋出到私有倉庫(我這裡用的是阿裡雲)
步驟:登入阿裡雲-->容器鏡像服務-->建立命名空間-->建立鏡像倉庫
# 第一次需要登入你的私庫
$ docker login --username=yourname registry.cn-hangzhou.aliyuncs.com
# 打tag
$ docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/shandz/redis:[鏡像版本号]
# push 推送到倉庫
$ docker push registry.cn-hangzhou.aliyuncs.com/shandz/redis:[鏡像版本号]
#從倉庫拉取鏡像
$ docker pull registry.cn-hangzhou.aliyuncs.com/shandz/redis:[鏡像版本号]
釋出到私有伺服器
步驟一 :下載下傳鏡像Docker Registry
docker pull registry
步驟二:運作私有庫Registry,相當于本地有個私有Docker hub
docker run -d -p 5000:5000 -v /szz/myregistry/:/tmp/registry --privileged=true registry
預設情況,倉庫被建立在容器的/var/lib/registry目錄下,建議自行用容器卷映射,友善于主控端聯調
驗證私服庫上有什麼鏡像(可通過curl指令)
curl -XGET http://ip:port/v2/_catalog
步驟三:将新鏡像修改符合私服規範的Tag
#按照公式: docker tag 鏡像:Tag Host:Port/Repository:Tag
docker tag 01372165b802 yourAddress:5000/myubuntu:1.1
步驟四:修改配置檔案使之支援http
vim /etc/docker/daemon.json
# "insecure-registries": ["yourAddress:5000"]
#docker預設不允許http方式推送鏡像,通過配置選項來取消這個限制。====> 修改完後如果不生效,建議重新開機docker
{
"registry-mirrors": ["https://vvnjr2qb.mirror.aliyuncs.com"],
"insecure-registries": ["yourAddress:5000"]
}
步驟五:推送到私服庫(push)
docker push yourAddress:5000/myubuntu:1.1