version: "3"
services:
mysql:
image: mysql
container_name: mysql
command:
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
volumes:
# 数据挂载
- /home/exam/mysql/data/:/var/lib/mysql/
# 配置挂载
- /home/exam/mysql/conf/:/etc/mysql/conf.d/
# 初始化目录挂载
- /home/exam/mysql/init/:/docker-entrypoint-initdb.d/
mycity:
# 指定容器名称
container_name: mycity
# 重启机制
restart: always
image: java:8
volumes:
# 本地jar包路径:容器内路径
- /home/exam/mycity.jar:/mycity.jar
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- ./logs:/logs
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
# 访问端口
ports:
- "8088:8088"
environment:
# 指定时区
- TZ="Asia/Shanghai"
#启动容器后执行的命令
entrypoint: java -server -Xms256m -Xmx256m -jar -Dserver.port=8088 -Dspring.profiles.active=local mycity.jar
/home/exam/mysql/init/:/docker-entrypoint-initdb.d/
这个的作用就是可以初始化sql脚本:<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.ftz.Demo.controller.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
tty: true
stdin_open: true
version: "3"
services:
mysql:
image: mysql
container_name: mysql
command:
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
volumes:
# 数据挂载
- /home/exam/mysql/data/:/var/lib/mysql/
# 配置挂载
- /home/exam/mysql/conf/:/etc/mysql/conf.d/
# 初始化目录挂载
- /home/exam/mysql/init/:/docker-entrypoint-initdb.d/
mycity:
# 指定容器名称
container_name: mycity
# 重启机制
restart: always
image: java:8
volumes:
# 本地jar包路径
- /home/exam/mycity.jar:/mycity.jar
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- ./logs:/logs
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
# 访问端口
ports:
- "8088:8088"
environment:
# 指定时区
- TZ="Asia/Shanghai"
#启动容器后执行的命令
tty: true
stdin_open: true
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/justleavel/article/details/122856968
内容来源于网络,如有侵权,请联系作者删除!
/home/exam/mysql/init/:/docker-entrypoint-initdb.d/
这个的作用就是可以初始化sql脚本: