一:我使用的是阿里雲的ubuntu16.4系統。java
項目數據庫:mysql
1 # 數據源 2 spring: 3 datasource: 4 type: com.zaxxer.hikari.HikariDataSource 5 driver-class-name: com.mysql.cj.jdbc.Driver 6 username: root 7 password: LOVEbai0921 8 url: jdbc:mysql://47.103.25.240:3306/personnel_file?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai 9 servlet: 10 multipart: 11 max-file-size: 20MB 12 max-request-size: 100MB 13 enabled: true 14 resolve-lazily: false 15 16 # mybaits-plus配置 17 mybatis-plus: 18 mapper-locations: classpath:/mapper/*Mapper.xml 19 global-config: 20 banner: false 21 #字段策略 0:"忽略判斷",1:"非 NULL 判斷"),2:"非空判斷" 22 field-strategy: 1 23 db-config: 24 table-underline: true 25 logic-delete-value: 1 26 logic-not-delete-value: 0 27 configuration: 28 map-underscore-to-camel-case: true 29 log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 30 server: 31 port: 8892
打包:spring
打包後在項目下會有個target文件夾。裏面有個打包的文件sql
docker : 建立Dockerfiledocker
1 FROM java:8 2 VOLUME /tmp 3 ADD inventoryManage-0.0.2.jar /inventory.jar 4 ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/inventory.jar"]
第一行是jdk 第二行是建立一個臨時文件夾 tmp 第三行,inventoryManage-0.0.2.jar 是打包的jar /inventory.jar 是自定義鏡像容器數據庫
把打包的文件,和Dockerfile放到同一個文件下。apache
建立鏡像命令:docker build -t inventory . (後面是 空格,點)ubuntu
啓動鏡像 inventory: docker run -d -p 8892:8892 --name inventory inventory安全
而後配置 阿里雲的安全組規則就能夠訪問了。mybatis