-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-compose-example.yml
55 lines (53 loc) · 1.72 KB
/
docker-compose-example.yml
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
version: '3.8'
networks:
simple-tiktok-test-net:
driver: bridge
services:
tiktok-mysql:
image: mysql:latest
container_name: tiktok-mysql
# 主机名,方便容器内互相通信
hostname: db
environment:
TZ: Asia/Shanghai #timeZone 时区
# 等同于 -e MYSQL_ROOT_PASSWORD指定root的登录密码
MYSQL_ROOT_PASSWORD: 'your MySQL root password'
MYSQL_ALLOW_EMPTY_PASSWORD: 'no'
# 这里这个指令compose启动成功后会自动创建名为simple_tiktok的数据库
MYSQL_DATABASE: 'simple_tiktok'
# 此处就是相当于 mysql create user,创建了数据库的登录用户
MYSQL_USER: 'tiktok'
MYSQL_PASSWORD: 'tiktokabc'
networks:
- simple-tiktok-test-net
ports:
- 33306:3306
volumes:
# 同步宿主机的时区
- "/etc/localtime:/etc/localtime:ro"
- "/etc/timezone:/etc/timezone:ro"
- ./config/docker/mysql/data:/var/lib/mysql
# 这里的my.cnf可以从原来的安装的MySQL里面找,如果没有不配置也不影响,只是为了方便外部更改
- ./config/docker/mysql/conf/my.cnf:/etc/my.cnf
- ./config/docker/mysql/init:/docker-entrypoint-initdb.d
command: --default-authentication-plugin=mysql_native_password
simple-tiktok:
depends_on:
- tiktok-mysql
build:
context: .
dockerfile: ./Dockerfile
args:
IMAGE_NAME: simple-tiktok # 镜像名称
IMAGE_TAG: compose # 镜像标签
container_name: simple-tiktok
networks:
- simple-tiktok-test-net
ports:
- 8967:8967
environment:
TZ: Asia/Shanghai
GOPROXY: https://goproxy.cn,direct
deploy:
restart_policy:
condition: on-failure