栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

虚拟机Docker Idea Java项目测试并部署

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

虚拟机Docker Idea Java项目测试并部署

Docker Idea Java项目测试并部署 1. 虚拟主机配置Docker服务

​ 如果使用idea编辑器的话,可以使用docker插件来远程使用服务器(虚拟机)上的docker,简单方便快捷的使用docker,更重要的是使用插件可以实现项目的一键部署,当然这还需要一些简单的配置。 默认的dokcer是不支持远程访问的,需要加点配置,开启Docker的远程访问

sudo vim /lib/systemd/system/docker.service

修改如下:

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket 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

# 注释此行,复制一行 最后添加 -H tcp://0.0.0.0:2375 如果有防火墙 必须allow 2375端口
# 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=infinit
# 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

sudo systemctl daemon-reload

sudo systemctl restart docker

sudo systemctl status docker

2. idea新建java项目

#创建Demo.java
public class Demo {
    public static void main(String[] args) {
        System.out.println("hello woeld");
    }
}

From ubuntu
Maintainer webrx 
Add jdk-18.tar.gz /usr/local/
Run mv /usr/local/jdk-18.0.1 /usr/local/jdk
Copy src/Demo.java /tmp
Env JAVA_HOME /usr/local/jdk
Env CLASSPATH .:$JAVA_HOME/lib
Env PATH .:$PATH:$JAVA_HOME/bin
Workdir /tmp
Volume /tmp
Run java Demo.java

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

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

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