0
点赞
收藏
分享

微信扫一扫

微服务自动化.Idea插件使用

茗越 2022-03-11 阅读 43

上一篇博客基础上修改

一、 Docker结合Idea插件使用

1、修改Docker服务文件,注释掉"ExecStart"这一行,并添加下面信息

docker.service:

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket containerd.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 fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375

ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes

# kill only the docker process, not all processes in the cgroup
KillMode=process
OOMScoreAdjust=-500

[Install]
WantedBy=multi-user.target

2、重新加载配置文件

systemctl daemon-reload

3、重启服务

systemctl restart docker

4、防火墙操作

firewall-cmd --zone=public --add-port=2375/tcp --permanent && firewall-cmd --reload && firewall-cmd --list-ports

5、查看端口号:

 firewall-cmd --list-port

6、IDEA

①、新建项目

 ②、文件 ->设置 ->插件

查看是否有该插件 

③、配置IDEA

④、查看docker 

 

 7、构建Springboot项目,生成Dockerfile,并完成镜像生成

①、增加 test.jar , Dockerfile

Dockerfile:

#1.指定基础镜像
FROM openjdk:8-jdk-alpine
#2.维护者信息
MAINTAINER mwy "mi0219@qq.com"
#3.创建/tmp目录并持久化到Docker数据文件夹,因为Spring Boot使用的内嵌Tomcat容器默认使用/tmp作为工作目录
VOLUME /tmp
#4.复制test1.jar到容器里(此处与之后的idea中使用docker插件一键发布是不一样的)
ADD test.jar /test.jar
#5.设置时区
ENV TZ=PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#6.声明运行时容器提供服务端口,这只是一个声明,在运行时并不会因为这个声明应用就会开启这个端口的服务
EXPOSE 8080
#7.指定容器启动程序及参数(相当于在容器中用cmd命令执行jar包)
ENTRYPOINT ["java","-jar","/test.jar"]
#下面的写法指定springboot项目启动时指定的额外参数
#ENTRYPOINT ["java","-jar","/test1.jar","--spring.config.location=/usr/local/project/docker/xxl-job/config/application.yml"]

②、新增镜像

docker build -t demo:1.0 .

举报

相关推荐

0 条评论