vim /lib/systemd/system/docker.service
[Service] Type=notify # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker #ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock ExecReload=/bin/kill -s HUP $MAINPID TimeoutSec=0 RestartSec=2 Restart=always2.重新加载配置文件并重启docker
systemctl daemon-reload && systemctl restart docker3.下载docker插件 4.配置idea的docker远程连接 5.配置pom.xml文件
6.编写dockerfile4.0.0 org.springframework.boot spring-boot-starter-parent2.6.3 com.example docker0.0.1-SNAPSHOT docker Demo project for Spring Boot 1.8 docker org.springframework.boot spring-boot-starter-weborg.springframework.boot spring-boot-starter-testtest org.springframework.boot spring-boot-maven-plugintrue truecom.example.docker.DockerApplication repackage com.spotify docker-maven-plugin1.0.0 http://ip地址:2375 ${docker.image.prefix}/${project.artifactId} src/main/docker / ${project.build.directory} ${project.build.finalName}.jar
FROM java:8 COPY *.jar /app.jar CMD ["--server.port=8080"] EXPOSE 8080 ENTRYPOINT ["java","-jar","app.jar"]6.打包镜像并上传 7.部署容器
总结 服务器docker要开放2375端口,使用阿里云或腾讯云要设置防火墙过滤规则。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)