docker教程(七)搭建自己的docker私服

docker教程(七)搭建自己的docker私服

绿林寻猫
2022-03-05 / 0 评论 / 282 阅读 / 正在检测是否收录...

前提

至于笔者为什么会写这篇文章,是因为共有docker服务的速度慢而且不私有,所以在自己设备上安装,以便对常用的镜像进行操作。如果对命令不是很熟悉的小伙伴,可以看看之前的文章来操作镜像和容器 《镜像、容器操作命令》

镜像安装

docker pull registry

通过命令查看现有镜像

docker images

l0d8wjod.png

后台启动容器,因为服务的默认端口是5000,而笔者本地已经5000端口已经占用了,所以指定了88端口。启动后访问http://ip:88/v2/_catalog成功就说明安装成功了

docker run -dp 88:88 registry

查看容器

docker ps

l0d907gw.png

镜像推送

以下以star7th/showdoc推送为例

docker push 127.0.0.1:88/uncle/star7th/showdoc  
#uncle为自己指定的仓库
#因为是本地推送,所以笔者用的是127.0.0.1,如果配置了域名的小伙伴也可以用域名
#执行后一般会提示出现错误,因为服务默认的仓库是镜像仓库是dockerhub,uncle/star7th/showdoc相当于docker.io/uncle/star7th/showdoc
#因此,想要将镜像推送到私服仓库中,需要修改镜像标签。
The push refers to repository [127.0.0.1:88/uncle/star7th/showdoc]
An image does not exist locally with the tag: 127.0.0.1:88/uncle/star7th/showdoc

修改镜像标签重新推送,走到这一步,镜像就推送成功了

docker tag star7th/showdoc 127.0.0.1:88/uncle/showdoc
docker push 127.0.0.1:88/uncle/showdoc

常用的请求URL

修改容器连接

Error response from daemon: Get "https://*:88/v2/": http: server gave HTTP response to HTTPS client

vim /etc/docker/daemon.json
#内容加入
{"insecure-registries":["填你的服务器地址"]}
0

评论 (0)

取消