docker pull registry docker run --name registry -p 5000:5000 -d registry http:// 192.168.174.130:5000/v2/_catalog
{ "repositories": [] }
vim /etc/docker/daemon.json
,添加如下的内容: "insecure-registries":["192.168.174.130:5000"]
systemctl restart docker
docker tag jdk8 192.168.174.130:5000/jdk8
: 标记该镜像
docker images
:此时查看镜像,发现多了一个 192.168.174.130:5000/jdk8
的镜像
docker push 192.168.174.130:5000/jdk8
:将标记的镜像上传到私有仓库中
此时再次访问 http:// 192.168.174.130:5000/v2/_catalog
,将会看到如下内容
{ "repositories": [ "jdk8" ] }
添加信任
"insecure-registries":["192.168.174.130:5000"]
systemctl restart docker
docker pull 192.168.174.130:5000/jdk8
修改 /etc/sysconfig/docker
文件: vim /etc/sysconfig/docker
在最下面添加一行 DOCKER_OPTS='-H unix:///var/run/docker.sock -H 0.0.0.0:2375'
vim /lib/systemd/system/docker.service
添加如下内容
systemctl daemon-reload systemctl restart docker
开启防火墙的端口: firewall-cmd --zone=public --add-port=2375/tcp --permanent
重新载入配置 firewall-cmd --reload
<build> <!-- 指定的最终打成jar包的名字 --> <finalName>demo</finalName> <plugins> <!-- SpringBoot的maven插件 --> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.4.13</version> <configuration> <!-- 注意imageName需要指定的`IP:端口/image_name`的格式--> <imageName>192.168.174.130:5000/${project.artifactId}:${project.version}</imageName> <!-- 指定基础镜像,不需要运行,相当于 from hub.c.163.com/library/java:8-alpine --> <baseImage>hub.c.163.com/library/java:8-alpine</baseImage> <!--覆盖相同标签镜像--> <forceTags>true</forceTags> <!-- 运行jar包 --> <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> <!-- 指定私有仓库所在服务器的2375端口,之前配置过可以远程访问的那个 --> <dockerHost>http://192.168.174.130:2375</dockerHost> </configuration> </plugin> </plugins> </build>
mvn clean package docker:build -DpushImage
mvn clean package docker:build -DpushImage
http://192.168.174.130:5000/v2/_catalog
,将会出现如下的内容 { "repositories": [ "demo" ] }
http://192.168.174.130:5000/v2/demo/tags/list
,可以看到demo这个镜像的所有版本
FROM hub.c.163.com/library/java:8-alpine ADD /demo.jar // ENTRYPOINT ["java", "-jar", "/demo.jar"]