栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

docker+idea一键部署

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

docker+idea一键部署

一、

[root@localhost ~]# systemctl disable firewalld --now
[root@localhost ~]# setenforce 0

二、
先去VMware Workstation Pro挂载镜像

[root@localhost ~]# mount /dev/sr0 /mnt/
[root@localhost ~]# mkdir /opt/centos/
[root@localhost ~]# cp -r /mnt/* /opt/centos/
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost ~]# rm -rf *
[root@localhost ~]# vi yum.repo
摁i 键,然后粘贴下面这段进去
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
摁 shift + : 输入wq 回车保存
[root@localhost ~]# yum repolist
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data  lvm2 wget 
[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

三、

[root@localhost ~]# yum install epel-release docker-ce container-selinux -y 
[root@localhost ~]# systemctl enable docker --now

四、

[root@localhost ~]# vi /etc/docker/daemon.json

粘贴下面这段进去
摁 i

{
  "insecure-registries" : ["0.0.0.0/0"],
"registry-mirrors": ["https://5twf62k1.mirror.aliyuncs.com"], 
  "exec-opts": ["native.cgroupdriver=systemd"]
}

shift+:
输入wq,回车保存

[root@localhost ~]# systemctl restart docker
[root@localhost ~]# vi /lib/systemd/system/docker.service

粘贴下面这段然后保存

[root@localhost ~]# ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375

#加载配置

[root@localhost ~]# systemctl daemon-reload

#重启服务

[root@localhost ~]# systemctl restart docker.service

然后打开idea新建项目




package com.example.testhello;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class testhello1 {
    @GetMapping("/test")
    public String hello(){
        return "hello test spring!";
    }
}




粘贴下面这段



    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.6.7
         
    
    com.example
    demo2
    0.0.1-SNAPSHOT
    demo2
    demo2
    
        1.8
    
    
        
            org.springframework.boot
            spring-boot-starter-web
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    

    
        
        ${project.artifactId}
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
            
            
                com.spotify
                docker-maven-plugin
                1.2.1
                
                
                    
                        build-image
                        
                        package
                        
                            build
                        
                    
                
                
                    
                    cainiao/${project.artifactId}
                    
                    
                        latest
                    
                    
                    java
                    
                    
                    /ROOT
                    
                    ["java", "-version"]
                    project.build.finalName}.jar是打包后生成的jar包的名字-->
                    ["java", "-jar", "/${project.build.finalName}.jar"]
                    
                    
                    http://10.83.234.130:2375
                    
                    
                        
                            /
                            
                            ${project.build.directory}
                            
                            ${project.build.finalName}.jar
                        
                    
                
            
        
    






有些idea版本不同,给端口会不一样,我这是2021版本的。



可以看到镜像和容器都构建成功了

访问http://虚拟机ip:8080/hello

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/880991.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号