DockerCompose

相关常用 docker-compose 收集

mysql-redis

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
version: "3.8" #Docker Engine Version 19.06+
services:
mysql:
image: mysql:5.7.29
container_name: mysql
command: --character_set_server=utf8mb4
--collation_server=utf8mb4_general_ci
--default_authentication_plugin=mysql_native_password
--lower_case_table_names=1
--log_bin_trust_function_creators=1
--max_allowed_packet=400M
--sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
environment:
MYSQL_ROOT_PASSWORD: admin
restart: always
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
- /root/docker/mysql/conf.d:/etc/mysql/conf.d
#解决时区问题
- /etc/localtime:/etc/localtime:ro

redis:
image: redis:latest
container_name: redis
# command: redis-server /etc/redis/redis.conf
restart: always
ports:
- "6379:6379"
volumes:
- /root/docker/redis/conf/redis.conf:/etc/redis/redis.conf
# curl -O http://download.redis.io/redis-stable/redis.conf 下载redis配置文件
- /root/docker/redis/data:/data
- /etc/localtime:/etc/localtime:ro

volumes:
mysql_data:
name: mysql_data
networks:
default:
my.cnf
1
2
3
4
5
6
7
8
9
10
11
12
13
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
#log-error = /var/log/mysql/error.log
# By default we only accept connections from localhost
#bind-address = 127.0.0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
max_allowed_packet=400M

sql-mode ="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Nexus

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
version: "2"

services:
nexus:
container_name: "nexus"
image: sonatype/nexus3
volumes:
- "nexus-data:/nexus_data"
ports:
- "8081:8081"

# 挂载已有卷组
volumes:
nexus-data:
external:
name: nexus_data

# 使用已有网桥
networks:
default:
external:
name: nginx-net

3.8 写法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
version: "3.8"
services:
nexus:
container_name: "nexus"
image: sonatype/nexus3
volumes:
- "nexus-data:/nexus-data"
ports:
- "8081:8081"
# 挂载已有卷组
volumes:
nexus-data:
external: true
name: nexus-data

# 使用已有网桥
networks:
default:
Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×