-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
36 lines (36 loc) · 1.02 KB
/
docker-compose.yml
File metadata and controls
36 lines (36 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 配置文件的版本
version: "3.8"
# 服务器群
services:
# 网页服务
django:
restart: always
# 用当前文件夹的Dockerfile来构建
build: .
# 在数据库搭建完成之后启动
depends_on:
- mysql
ports:
- 8000:8000
# 把当前文件夹映射为django的工作目录,从而达到本地修改同步到容器的效果
volumes:
- .:/xk
# 运行命令
command: sh -c "python3 manage.py makemigrations xk_models && python3 manage.py migrate && python3 manage.py runserver 0.0.0.0:8000"
# 数据库服务
mysql:
# 使用最新的mysql镜像
image: mysql
# restart: always
# 数据库的端口映射到本地3306
ports:
- 3306:3306
environment:
MYSQL_DATABASE : "xk"
MYSQL_ROOT_PASSWORD : 123456
command: --default-authentication-plugin=mysql_native_password
volumes:
# 数据文件
- ./mysql/xk.sql:/xk.sql
# 配置文件(默认文件编码存在问题
- ./mysql/conf.d:/etc/mysql/conf.d