docker run -d --name registry -p 5000:5000 registry
修改/etc/hosts
172.20.16.185 local-registry
本地为http,需要配置
# cat /etc/docker/daemon.json
{
"insecure-registries" : ["local-registry:5000"]
}
因本地为x86环境,默认是拉取不到arm64架构的镜像的,需要指定--platform参数
docker pull --platform arm64 python:3.9.6-alpine3.13
// 为了后续push到镜像仓库,也防止与amd架构镜像名冲突
docker tag python:3.9.6-alpine3.13 local-registry:5000/python:3.9.6-alpine3.13-arm64
// 本地为x86,可不加--platform参数
docker pull --platform amd64 python:3.9.6-alpine3.13
docker tag python:3.9.6-alpine3.13 local-registry:5000/python:3.9.6-alpine3.13-amd64
必须要有这一步,创建多架构镜像时是从镜像仓库拉取镜像,不是从本地
docker push local-registry:5000/python:3.9.6-alpine3.13-arm64
docker push local-registry:5000/python:3.9.6-alpine3.13-amd64
http仓库,因此需要加上--insecure参数
docker manifest create --insecure local-registry:5000/python:3.9.6-alpine3.13 local-registry:5000/python:3.9.6-alpine3.13-arm64 local-registry:5000/python:3.9.6-alpine3.13-amd64
Created manifest list local-registry:5000/python:3.9.6-alpine3.13
docker manifest inspect local-registry:5000/python:3.9.6-alpine3.13
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1368,
"digest": "sha256:2218325573351688f74a604f67e643f26bf7851c92d65849077d023516bd629f",
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1368,
"digest": "sha256:19256666830f70a3621ac44fa32e1a09f40be3ef168d86329891569fcecdefd4",
"platform": {
"architecture": "arm64",
"os": "linux"
}
}
]
}
以后pull该镜像时,机器架构是什么,就会自动拉取当前架构的镜像
docker manifest push --insecure local-registry:5000/python:3.9.6-alpine3.13
docker manifest rm local-registry:5000/python:3.9.6-alpine3.13
前面已经推送到镜像仓库的xxx-arm64的镜像或者xxx-amd64的镜像可以不用管,镜像都是复用的,并不会占用存储空间,只是多了个tag,如果非要删的话,本地镜像仓库怎么去删除tag我没去看,如果是使用的harbor,直接去页面删除tag即可