20.5. 将容器推送到私有注册中心
使用 buildah push 命令将镜像从本地存储推送到公共或私有存储库。
先决条件
-
container-tools模块已安装。 - 镜像是使用 Containerfile 中的指令构建的。详情请参阅 使用 Buildah 从 Containerfile 构建镜像 一节。
流程
在机器上创建本地注册中心:
# podman run -d -p 5000:5000 registry:2将
myecho:latest镜像推送到localhost注册中心:# buildah push --tls-verify=false myecho:latest localhost:5000/myecho:latest Getting image source signatures Copying blob sha256:e4efd0... ... Writing manifest to image destination Storing signatures
验证
列出
localhost存储库中的所有镜像:# curl http://localhost:5000/v2/_catalog {"repositories":["myecho2]} # curl http://localhost:5000/v2/myecho2/tags/list {"name":"myecho","tags":["latest"]}检查
docker://localhost:5000/myecho:latest镜像:# skopeo inspect --tls-verify=false docker://localhost:5000/myecho:latest | less { "Name": "localhost:5000/myecho", "Digest": "sha256:8999ff6050...", "RepoTags": [ "latest" ], "Created": "2021-06-28T14:44:05.919583964Z", "DockerVersion": "", "Labels": { "architecture": "x86_64", "authoritative-source-url": "registry.redhat.io", ... }拉取
localhost:5000/myecho镜像:# podman pull --tls-verify=false localhost:5000/myecho2 # podman run localhost:5000/myecho2 This container works!