Press "Enter" to skip to content

Docker运行java程序,从环境变量注入jvm运行参数

FROM java:8

ADD ./target/demo.jar /app/

RUN  echo "Asia/Shanghai" > /etc/timezone
RUN  dpkg-reconfigure -f noninteractive tzdata

EXPOSE 8080

ENTRYPOINT exec java $JAVA_OPTS -jar /app/demo.jar
version: '3.5'
services:
  demo:
    image: demo
    build: ./demo
    healthcheck:
      test: ["CMD-SHELL", "curl -sS 127.0.0.1:8080 || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    deploy:
      mode: replicated
      replicas: 4
      endpoint_mode: dnsrr
      update_config:
        parallelism: 1
        failure_action: pause
        delay: 30s
        order: start-first
    networks:
      - public
      - default
    environment:
      SPRING_PROFILES_ACTIVE: test
      JAVA_OPTS: "-Xmx2048m"
    restart: always
    logging:
      options:
        max-size: "10m"
        max-file: "10"
发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注