大家好,欢迎来到IT知识分享网。
##实例
FROM java:8
VOLUME /tmp
ADD app.jar app.jar
RUN bash -c ‘touch /app.jar’
EXPOSE 9001
ENV JAVA_OPTS=”\
-server \
-Xmx4g \
-Xms4g \
-Xmn2g \
-XX:SurvivorRatio=8 \
-XX:MetaspaceSize=256m \
-XX:MaxMetaspaceSize=512m \
-XX:+UseParallelGC \
-XX:ParallelGCThreads=4 \
-XX:+UseParallelOldGC \
-XX:+UseAdaptiveSizePolicy \
-XX:+PrintGCDetails \
-XX:+PrintTenuringDistribution \
-XX:+PrintGCTimeStamps \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=/ \
-Xloggc:/gc.log \
-XX:+UseGCLogFileRotation \
-XX:NumberOfGCLogFiles=5 \
-XX:GCLogFileSize=10M”
ENTRYPOINT java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /app.jar
不过这种方式在dockerfile写死了不灵活,不是很推荐,特别是要区分env的应用来说。
##docker run指定
docker run –rm -e JAVA_OPTS=’-Xmx1g’ tomcat
##docker-compose方式指定
environment:
– JVM_OPTS=-Xmx12g -Xms12g -XX:MaxPermSize=1024m
##k8s指定
apiVersion: v1
kind: ReplicationController
metadata:
labels:
app: jenkins
role: master
version: v1
name: jenkins-master
namespace: jenkins
spec:
replicas: 1
selector:
app: jenkins
role: master
version: v1
template:
metadata:
labels:
app: jenkins
role: master
version: v1
spec:
containers:
– env:
– name: JENKINS_OPTS
value: –prefix=
– name: JAVA_OPTS
value: -Djava.awt.headless=true -Xmx200m -Dcom.sun.management.jmxremote=
-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
image: jenkins:2.7.2
name: jenkins
ports:
– containerPort: 8080
name: web
– containerPort: 50000
name: leader
resources:
limits:
cpu: 1000m
memory: 800Mi
requests:
cpu: 100m
memory: 400Mi
volumeMounts:
– mountPath: /var/jenkins_home
name: jenkins-master
nodeSelector:
worker: “true”
volumes:
– name: jenkins-master
nfs:
path: /data/jenkins-master
server: ‘{
{nfs_server}}’
##doc
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/15560.html