代码之家  ›  专栏  ›  技术社区  ›  silentsudo

为MySQL/Tomcat/Maven Java Webapp创建Docker文件

  •  0
  • silentsudo  · 技术社区  · 8 年前

    如何为MySQL/Tomcat/Maven项目创建DockerFile。

    #FROM openjdk:8-jdk-alpine
    FROM openjdk:8-jre-alpine
    
    #VOLUME /tmp
    
    COPY target/notifier-0.0.1-SNAPSHOT.jar /notifier.jar
    
    CMD [ "/usr/bin/java", "-jar", "-Dspring.profiles.active=test", "/notifier.jar" ]
    
    #Build command => docker build -f DockerFile -t notifier:latest .
    #RUN command => docker run -p 9090:8072 notifier
    #Image Path => ~/Library/Containers/com.docker.docker/Data/...
    
    #Save Image Locally => docker save -o notifier.tar notifier
    #Load Image Locally => docker load -i notifier.tar notifier
    #Run Image Locally => docker run -d --restart=always -p newport:original_port notifier
    

    但是现在我想使用单独的mysql/tomcat,我需要对这个或任何引用资源添加什么样的更改将是有帮助的。

    2 回复  |  直到 8 年前
        1
  •  1
  •   gCoh    8 年前

    version: '3.1'
    
    services:
    
      db:
        image: mysql
        command: --default-authentication-plugin=mysql_native_password
        restart: always
        environment:
          MYSQL_ROOT_PASSWORD: example
    
      whatever-other-service:
        image: whateverimage
        restart: always
        ports:
          - 8080:8080
    

    并使用 docker-compose up

        2
  •  1
  •   Kishore    8 年前

    在Dockerfile中使用此图像(mysql、tomcat、ant和maven)

    From guligo/jdk-maven-ant-tomcat-mysql
    
    推荐文章