效果
安装
1.创建目录
cd /opt
mkdir -p kod/{db,site}
cd /opt/kod
2.环境文件
vim db.env
内容如下
MYSQL_PASSWORD=123456
MYSQL_DATABASE=kodbox
MYSQL_USER=kodbox
3.编写docker-compose.yml
vim docker-compose.yml
内容如下
version: '3.5'services:db:image: mariadb:10.6restart: alwayscommand: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROWvolumes:- "./db:/var/lib/mysql" #./db是数据库持久化目录,可以修改# - "./etc/mysql/conf.d:/etc/mysql/conf.d" #增加自定义mysql配置environment:- MYSQL_ROOT_PASSWORD=123456- MARIADB_AUTO_UPGRADE=1- MARIADB_DISABLE_UPGRADE_BACKUP=1env_file:- db.envapp:image: kodcloud/kodboxrestart: alwaysports:- 10001:80 #左边80是使用端口,可以修改volumes:- "./site:/var/www/html" #./site是站点目录位置,可以修改environment:- MYSQL_HOST=192.168.168.1- REDIS_HOST=192.168.168.1env_file:- db.envdepends_on:- db- redisredis:image: redis:alpinerestart: alwaysports:- 6380:6380
使用
打开浏览器,输入地址
http://localhost:10001/