两种Dockerfile文件配置

2023-05-16

注意:xxx是您的项目名称!-Xmx:堆最大值;-Xms:堆初始值
COPY指令只能从执行docker build所在的主机上读取资源并复制到镜像中。
而ADD指令还支持通过URL从远程服务器读取资源并复制到镜像中。
Docker开发者推荐:满足同等功能的情况下,推荐使用COPY指令。ADD指令更擅长读取本地tar文件并解压缩。

springboot版本:

FROM openjdk:8
MAINTAINER "hsj<2356899074@qq.com>"
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY xxx.jar /xxx.jar
EXPOSE 7788
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dfile.encoding=utf-8","-jar","-Xmx2048m","-Xms1024m","/xxx.jar","--spring.profiles.active=dev"]

tomcat版本:

FROM tomcat:8.0-jre8
MAINTAINER "hsj<2356899074@qq.com>"
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY ./xxx.war /usr/local/tomcat/webapps/xxx.war
COPY ./server.xml /usr/local/tomcat/conf/server.xml
ENV JAVA_OPTS="-Xms2048m -Xmx5120m"
EXPOSE 8080


server.xml

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
         This connector uses the NIO implementation that requires the JSSE
         style configuration. When using the APR/native implementation, the
         OpenSSL style configuration is required as described in the APR/native
         documentation -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine name="Catalina" defaultHost="localhost">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>


      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase=""
            unpackWARs="true" autoDeploy="false">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.RemoteIpValve"
               remoteIpHeader="X-Forwarded-For"
               protocolHeader="X-Forwarded-Proto"
               protocolHeaderHttpsValue="https"/>
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
       <Context path="" docBase="/usr/local/tomcat/webapps/xxx" reloadable="false"/>
      </Host>
    </Engine>
  </Service>
</Server>

后台启动:nohup xxx &

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

两种Dockerfile文件配置 的相关文章

随机推荐

  • 嵌入式前景怎么样

    现在物联网的发展也把之前大家没有注意过的嵌入式给带动起来了 xff0c 其实想去学习嵌入式的人还真不少 xff0c 不过这其中也会有人担心自己的发展前景 xff0c 下面可以一起先来了解下嵌入式前景怎么样 目前 xff0c 嵌入式开发人才需
  • datax同步数据:数据源:mongo,目标源:hdfs

    一 配置文件mongo hdfs json 34 job 34 34 setting 34 34 speed 34 34 channel 34 2 34 content 34 34 reader 34 34 name 34 34 mongo
  • 做程序媛这几年,感受?体验?

    首先 感受 和男程序员一个样 真不是废话 BUG是修不完的 但是不能放过它 因为你的内心会遭受煎熬 直接进入体验 就不用重复的文字去啰嗦了 直接上图哈 以下的这几种情况 在我的生活中 是真的不断出现 连样式都没变过 first 修电脑AND
  • 天猫精灵与oauth的认证接入流程(AliGenie智能家居接入流程)

    写在前面的叨叨 xff1a 对于天猫精灵的对接网上的教程也是颇少的 xff0c 所以希望我的记录过程也能对他人学习有所帮助 xff0c 要想学一样新的技术必须得找到相关技术文章好好专研了 xff0c 在学习的路上孜孜不倦 xff0c 偶遇难
  • 致敬2016年我的每一次选择。

    2016年 对我来说 是不平凡的 不是因为经历了什么永生难忘的经历也不是因为我做了什么伟大的事情 只是因为毕业了 我毕业了 多么开心却又悲伤的故事 我开心在我终于可以做自己想做的事情 悲伤的是当同学们的父母都陆续为他们铺好以后的路的时候 我
  • 打开计算机的管理需要在控制面板中创建关联

    今天在工作中发现当我选择计算机 管理时提示我需要在控制面板中创建关联 xff0c 如下图所示 xff1a 于是 xff0c 我便上百度搜索了一下 xff0c 答案是这样的 xff1a 修改 span style font family no
  • ftp身份认证时登录框反复弹出以及ftp常用配置

    1 若我们想访问一个人的ftp站点 xff0c 直接通过浏览器直接访问就可以了 xff08 ftp 要访问主机A的IP地址 xff09 如果对方开启了基本身份认证的话 xff0c 我们就需要输入正确的用户名及密码才可正常访问 xff0c 即
  • Linux下挂载U盘、ISO、光盘、rpm

    1 挂载U盘 1 xff09 将U盘连接到虚拟机后 xff0c 使用fdisk l xff08 注意 xff0c 这是list单词的首字母l xff09 命令查看当前U盘的设备符号 2 xff09 创建目录 mnt usb xff0c 以备
  • unity 3D学习日记:创建一个小场景并编写简单C#移动脚本

    学习Unity 3D第一周 xff0c 完成的目标一是创建一个小场景 xff0c 用角色控制器在场景里行走 xff1b 二是编写一个简单的移动脚本 一 创建一个小场景 xff0c 用角色控制器在场景里行走 1 先安装Unity 3D 5 3
  • 基于Unity3D平台的三维虚拟城市研究与应用

    0 引 言 随着现代城市的不断拓展延伸 城市空间多层次 立体模式管理逐渐成为城市规划管理的发展趋势 1 实现城市空间信息管理模式从二维到三维的转变 三维虚拟城市技术 已经成为人们关注和研究的热点 2 三维虚拟系统具有多维信息处理 表达和分析
  • unity:C#控制人在真实环境中行走

    自己在学习unity的课程中遇到了 xff0c 有的地方还没怎么太理解上去 xff0c 先做个笔记 xff0c 顺便看看有没有需要的人 1 搭建一个小场景 xff0c 一个需要控制的 人 xff08 添加CharacterControlle
  • unity 3D:自动寻路

    首先 xff0c 搭建一下场景 xff0c 场景要求 xff1a 有遮挡 xff0c 设置好不可走区域为navigation static 以及 not walkable 在人身上添加Nav Mesh Agent 设置好后勾选显示导航网格
  • 数据结构 ——c++实现(知识点集合)

    数据结构 c 43 43 实现 xff08 知识点集合 xff09 某不知名学狗的复习记录 xff0c 包含数据结构基本概念 xff0c 线性表 xff0c 栈 队列 递归 xff0c 串 数组 广义表和树和森林内容整理 主要整理了知识点
  • Unity3D 使用SceneManager跳转/加载场景

    很久没有更新博客了 xff0c 最近也是还在学习U3D 下面写一下使用SceneManager跳转 加载场景 我们假设要点击一个按钮跳转 xff0c 那么我们只要把跳转的代码写进按钮点击事件里就好了 其实加载场景很简单 xff0c 只需要写
  • [OpenCV] aruco Markers识别 小车巡线

    小车巡线代码 include lt ros ros h gt include lt sensor msgs Image h gt include lt geometry msgs Twist h gt include lt cv bridg
  • 备份ubuntu

    在使用Ubuntu之前 xff0c 相信很多人都有过使用Windows系统的经历 如果你备份过Windows系统 xff0c 那么你一定记忆犹新 xff1a 首先需要找到一个备份工 具 通常都是私有软件 xff0c 然后重启电脑进入备份工具
  • Docker - docker build 命令详解

    docker build 命令原理 docker build 命令从 Dockerfile 和上下文构建镜像构建的上下文 xff1a 位于指定 PATH 或 URL 中的一组文件构建过程可以引用上下文中的任何文件 xff0c 例如 xff0
  • RealSense二次开发

    转载 xff1a librealsense2查看相机设备信息 JavaShuo 文章目录 1 librealsense2设备信息读取 xff12 xff0e realsense 投影函数和反投影函数3 深度相机与彩色相机的坐标变换 1 li
  • 大规模MIP的精确算法和实现

    大规模MIP的精确算法和实现 大规模MIP的精确算法和实现 xff1a 目录第1部分 xff1a CPLEX的Java API详解1 CPLEX简介2 构建简单的模型3 CPLEX的高级应用 第2部分 xff1a Gurobi的Python
  • 两种Dockerfile文件配置

    注意 xff1a xxx是您的项目名称 xff01 Xmx xff1a 堆最大值 xff1b Xms xff1a 堆初始值 COPY指令只能从执行docker build所在的主机上读取资源并复制到镜像中 而ADD指令还支持通过URL从远程