RUN /etc/init.d/mariadb start && \ mysql -e "CREATE USER 'test'@'%' IDENTIFIED BY 'test';" && \ mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' WITH GRANT OPTION;" && \ mysql -e "" && \ mysql -e "FLUSH PRIVILEGES;"
# Set the container's startup command to apache2-foreground and start MariaDB service CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
# 安装PDO MySQL扩展 RUN docker-php-ext-install pdo_mysql
# 安装MySQLi扩展 RUN docker-php-ext-install mysqli
# 安装MariaDB 10.3 RUN apt-get install -y mariadb-server-10.3
# 设置MySQL root 用户密码和创建新用户 RUN service mysql start && \ mysql -e "UPDATE mysql.user SET Password = PASSWORD('your_root_password') WHERE User = 'root';" && \ mysql -e "CREATE USER 'your_user'@'%' IDENTIFIED BY 'your_password';" && \ mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'your_user'@'%' WITH GRANT OPTION;" && \ mysql -e "FLUSH PRIVILEGES;"
# Expose ports EXPOSE80 EXPOSE3306
# 设置容器的启动命令为apache2-foreground和启动MariaDB服务 CMD ["bash", "-c", "apache2-foreground & service mysql start && tail -f /dev/null"]