Dockerfile模板和Docker Compose模板

记录一下Dockerfile模板和Docker Compose模板,

基础的系统加JDK环境来构建一个Java应用,其Dockerfile内容如下:

# 基础镜像
FROM openjdk:11.0-jre-buster
# 设定时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 拷贝jar包
COPY docker-demo.jar /app.jar
# 入口
ENTRYPOINT ["java", "-jar", "/app.jar"]

用docker-compose.yml 模板文件实现多个相互关联的Docker容器的快速部署:

version: "3.8"

services:
  mysql:
    image: mysql
    container_name: mysql
    ports:
      - "3306:3306"
    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: 123
    volumes:
      - "./mysql/conf:/etc/mysql/conf.d"
      - "./mysql/data:/var/lib/mysql"
      - "./mysql/init:/docker-entrypoint-initdb.d"
    networks:
      - hm-net
  hmall:
    build: 
      context: .
      dockerfile: Dockerfile
    container_name: hmall
    ports:
      - "8080:8080"
    networks:
      - hm-net
    depends_on:
      - mysql
  nginx:
    image: nginx
    container_name: nginx
    ports:
      - "18080:18080"
      - "18081:18081"
    volumes:
      - "./nginx/nginx.conf:/etc/nginx/nginx.conf"
      - "./nginx/html:/usr/share/nginx/html"
    depends_on:
      - hmall
    networks:
      - hm-net
networks:
  hm-net:
    name: hmall

相关推荐

  1. Dockerfile模板Docker Compose模板

    2023-12-15 01:10:02       56 阅读
  2. Dockerfile.gitlab-ci.yml文件模板

    2023-12-15 01:10:02       57 阅读
  3. DockerCompose

    2023-12-15 01:10:02       62 阅读
  4. Centos7安装DockerDockerCompose

    2023-12-15 01:10:02       30 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-15 01:10:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-15 01:10:02       101 阅读
  3. 在Django里面运行非项目文件

    2023-12-15 01:10:02       82 阅读
  4. Python语言-面向对象

    2023-12-15 01:10:02       91 阅读

热门阅读

  1. 基于sfunction builder的c-sfunction编写及案例测试分析

    2023-12-15 01:10:02       48 阅读
  2. Linux如何对文件进行分割和重组

    2023-12-15 01:10:02       66 阅读
  3. Py-While循环语句

    2023-12-15 01:10:02       50 阅读
  4. MybatisPlus的分页插件

    2023-12-15 01:10:02       51 阅读
  5. DatabaseMetaData详解

    2023-12-15 01:10:02       52 阅读
  6. AI元素深化人类发展之路:挑战与趋势

    2023-12-15 01:10:02       57 阅读
  7. static关键字详解

    2023-12-15 01:10:02       48 阅读
  8. Python的模块与包

    2023-12-15 01:10:02       64 阅读
  9. CAN静默回环模式测试

    2023-12-15 01:10:02       55 阅读
  10. Oracle开发和应用——基本SQL语句2(SELECT)

    2023-12-15 01:10:02       61 阅读