1.在原有的docker服务基础上,下拉一个 镜像:
docker pull registry:2.6.2
2.运行:
docker run -d -p 5000:5000 --restart=always --name registry registry:2.6.2
3.将自己的镜像推送到私有仓库:
例如:docker.io/langwanghuangshifu/eureka-server:latest
docker push localhost:5000/langwanghuangshifu/eureka-server:latest
运行提示:
The push refers to a repository [localhost:5000/langwanghuangshifu/eureka-server] An image does not exist locally with the tag: localhost:5000/langwanghuangshifu/eureka-server
此时,会发现推送失败,由于docke hub 为默认的镜像仓库,推送命令实质上为:docker push docker.io/langwanghuangshifu/eureka-server:latest
因此需要将上述镜像更改镜像标签:
docker tag langwanghuangshifu/eureka-server:latest localhost:5000/langwanghuangshifu/eureka-server:latest
再次执行:
docker push localhost:5000/langwanghuangshifu/eureka-server:latest
推送成功:
4.查看私有仓库的镜像:
- 镜像列表:
[root ~]# curl http://localhost:5000/v2/_catalog
{"repositories":["langwanghuangshifu/eureka-server"]}
- 具体某个镜像的标签列表:
curl http://localhost:5000/v2/镜像名/tags/list
例如:langwanghuangshifu/eureka-server
[root ~]# curl http://localhost:5000/v2/langwanghuangshifu/eureka-server/tags/list
{"name":"langwanghuangshifu/eureka-server","tags":["latest"]}