diff --git a/TestDocker/MySQL/Dockerfile b/TestDocker/MySQL/Dockerfile new file mode 100644 index 0000000..5b14e00 --- /dev/null +++ b/TestDocker/MySQL/Dockerfile @@ -0,0 +1,17 @@ +# 使用MySQL官方镜像 +FROM mysql:latest + +# 设置环境变量 +ENV MYSQL_ROOT_PASSWORD=123456 +ENV MYSQL_DATABASE=mydb + +# 开放3306端口 +EXPOSE 3306 + +# MySQL配置 +# 允许远程访问 +COPY my.cnf /etc/mysql/conf.d/my.cnf + +# 健康检查 +HEALTHCHECK --interval=30s --timeout=3s \ + CMD mysql -uroot -p"${MYSQL_ROOT_PASSWORD}" -e "SELECT 1" || exit 1 \ No newline at end of file diff --git a/TestDocker/MySQL/README.txt b/TestDocker/MySQL/README.txt new file mode 100644 index 0000000..e0a25fd --- /dev/null +++ b/TestDocker/MySQL/README.txt @@ -0,0 +1,5 @@ +docker build -t mysql-server . +docker run -d \ + -p 3306:3306 \ + --name mysql-container \ + mysql-server \ No newline at end of file diff --git a/TestDocker/MySQL/my.cnf b/TestDocker/MySQL/my.cnf new file mode 100644 index 0000000..ff1b64f --- /dev/null +++ b/TestDocker/MySQL/my.cnf @@ -0,0 +1,2 @@ +[mysqld] +bind-address = 0.0.0.0 \ No newline at end of file