配置服务端:
#拉取镜像
docker pull registry
#创建指定目录
mkdir /usr/local/docker/registry
#创建文件docker-compose.yml
vim docker-compose.yml
#文件内容如下:
version: '3.1'
services:
registry:
image: registry
restart: always
container_name: registry
ports:
- 5000:5000
volumes:
- /usr/local/docker/registry/data:/var/lib/registry
#启动docker-compose
docker-compose up
#浏览器访问
http://ip:5000/v2/
图片.png
配置客户端(将项目打成镜像,放进私服中,客户端拉取即可启动运行):
#修改docker配置文件
vim /etc/docker/daemon.json
#文件加入:
"insecure-registries": [
"ip:5000"
]
#重新启动服务:
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
图片.png
#以tomcat为例,将tomcat上传到私服:
docker tag tomcat ip:5000/tomcat
docker push ip:5000/tomcat
#私服拉取镜像:
docker pull ip:5000/tomcat
网友评论