拉取仓库镜像:
docker pull registry创建容器:
docker run -di --name=registry -p 5001:5000 registry-
查看私有仓库安装是否成功:
浏览器输入:http://ip:5001/v2/_catalog
配置私服
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]# vi /etc/docker/daemon.json
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]# systemctl restart docker
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],
"insecure-registries":["ip:5001"]
}
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]# docker tag jdk1.8 ip:5001/jdk1.8
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
47.95.228.162:5001/jdk1.8 latest b5984b02f4fb 19 minutes ago 589MB
jdk1.8 latest b5984b02f4fb 19 minutes ago 589MB
redis latest f7302e4ab3a8 37 hours ago 98.2MB
nginx latest 4733136e5c3c 43 hours ago 126MB
tomcat 7-jre7 47c156f4d4e3 3 months ago 359MB
centos/mysql-57-centos7 latest e35b3f7a4ea0 4 months ago 452MB
centos 7 9f38484d220f 5 months ago 202MB
registry latest f32a97de94e1 5 months ago 25.8MB
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
add44bfbee32 registry "/entrypoint.sh /etc…" 11 minutes ago Exited (2) 3 minutes ago registry
675559f047fd redis "docker-entrypoint.s…" 16 hours ago Exited (0) 3 minutes ago docker_redis
c65dbb6334eb nginx "nginx -g 'daemon of…" 16 hours ago Exited (0) 3 minutes ago docker_nginx
af6959041f0e tomcat:7-jre7 "catalina.sh run" 17 hours ago Exited (143) 3 minutes ago docker_tomcat
aa1a205374a7 centos/mysql-57-centos7 "container-entrypoin…" 17 hours ago Exited (0) 3 minutes ago docker_mysql
3ac48779f319 centos:7 "/bin/bash" 19 hours ago Exited (137) 3 minutes ago mycentos2
- 重启docker:
systemctl restart docker - 对需要上传的镜像做标记
docker tag jdk1.8 ip:5001/jdk1.8 - 启动私服:
docker start registry - 上传镜像:
docker push ip:5001/jdk1.8 - 浏览器输入:http://ip:5001/v2/_catalog
- 另一台服务器如果要拉取这个镜像
1. 在/etc/docker/daemon.json中加入:
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],
"insecure-registries":["47.95.228.162"]
}
2. 重启docker
systemctl restart docker
3. 标记镜像
docker tag jdk1.8 47.95.228.162:5001/jdk1.8
4. 拉取jdk1.8镜像
docker pull 47.95.228.162:5001/jdk1.8