MariaDB
创建数据目录和配置文件
1
| sudo mkdir -p /data/mariadb/{data,conf.d}
|
1
2
3
4
5
6
7
8
9
10
11
| cat << EOF | sudo tee /data/mariadb/conf.d/my.cnf
[mariadb]
server_id=1
character-set-server=utf8mb4 # default
collation-server=utf8mb4_general_ci # default
lower_case_table_names=1
max_connections=10000
max_connect_errors=100000
innodb_buffer_pool_size=4294967296 # 4G. default 128M
max_allowed_packet=1073741824 # 1G. default 16M
EOF
|
如果镜像有安装tzdata,加上TZ变量即可修改时区。
1
| sudo docker network create --subnet=172.18.0.0/16 dbnet
|
1
2
3
4
5
6
7
8
9
| sudo docker run -d --name mariadb01 \
-e TZ='Asia/Shanghai' \
-e MYSQL_ROOT_PASSWORD='123456' \
-p 3306:3306 \
-v /data/mariadb/data:/var/lib/mysql \
-v /data/mariadb/conf.d:/etc/mysql/conf.d \
--network dbnet \
--restart always \
mariadb:10.5
|
本地如需要mysql客户端工具,最小安装即可
1
| apt search mariadb-client
|
1
| sudo apt-get -y install mariadb-client-core-10.3 # 只有mysql命令
|
或者
1
| sudo apt-get -y install mariadb-client # 包含mysqladmin,mysqldump等命令
|
进入容器
1
| sudo docker exec -it mariadb01 bash
|
不进入容器执行sql语句两种方法
1
2
3
| mysql -h 127.0.0.1 -P 3306 -u root -p'123456' -e "create user testuser identified by '123456';"
sudo docker exec mariadb01 /bin/bash -c "mysql -u root -p'123456' -e 'create database testdb;'"
|
Redis
可选项,数据持久化,--appendonly yes
1
| sudo docker run --name myredis -d -e TZ='Asia/Shanghai' --network=host --restart=always -v /data/myredis:/data redis:alpine redis-server --appendonly yes --maxmemory 2GB --requirepass '123456'
|
xxl-job
xxl-job官网
初始化数据库,官方sql脚本链接
访问控制台默认帐号密码:admin/123456
,此镜像已设置过TZ变量
1
2
3
4
5
6
| sudo docker run \
-e PARAMS="--spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai \
--spring.datasource.username=root \
--spring.datasource.password=123456 \
--spring.datasource.driver-class-name=com.mysql.jdbc.Driver" \
-p 8080:8080 -v /tmp:/data/applogs --name xxl-job-admin --restart always -d xuxueli/xxl-job-admin:2.3.0
|
Nacos
单机版nacos
初始化数据库,官方sql脚本链接
访问控制台默认帐号密码:nacos/nacos
拷贝默认配置文件application.properties
1
2
3
4
| sudo docker run -d --name nacos-tmp -e MODE=standalone nacos/nacos-server
sudo mkdir -p /data/mynacos/conf
sudo docker exec nacos-tmp cat /home/nacos/conf/application.properties | sudo tee /data/mynacos/conf/application.properties
sudo docker stop nacos-tmp && sudo docker rm -v nacos-tmp
|
application.properties配置文件参考,修改数据库连接相关部分即可
# spring
server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos}
server.contextPath=/nacos
server.port=${NACOS_APPLICATION_PORT:8848}
spring.datasource.platform=mysql
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
db.num=1
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.url.1=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user=nacosadmin
db.password=123456
### The auth system to use, currently only 'nacos' is supported:
nacos.core.auth.system.type=${NACOS_AUTH_SYSTEM_TYPE:nacos}
### The token expiration in seconds:
nacos.core.auth.default.token.expire.seconds=${NACOS_AUTH_TOKEN_EXPIRE_SECONDS:18000}
### The default token:
nacos.core.auth.default.token.secret.key=${NACOS_AUTH_TOKEN:SecretKey012345678901234567890123456789012345678901234567890123456789}
### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
nacos.core.auth.caching.enabled=${NACOS_AUTH_CACHE_ENABLE:false}
nacos.core.auth.enable.userAgentAuthWhite=${NACOS_AUTH_USER_AGENT_AUTH_WHITE_ENABLE:false}
nacos.core.auth.server.identity.key=${NACOS_AUTH_IDENTITY_KEY:serverIdentity}
nacos.core.auth.server.identity.value=${NACOS_AUTH_IDENTITY_VALUE:security}
server.tomcat.accesslog.enabled=${TOMCAT_ACCESSLOG_ENABLED:false}
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
# default current work dir
server.tomcat.basedir=
## spring security config
### turn off security
nacos.security.ignore.urls=${NACOS_SECURITY_IGNORE_URLS:/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**}
# metrics for elastic search
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
nacos.naming.distro.taskDispatchThreadCount=10
nacos.naming.distro.taskDispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataRatio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true
启动nacos单机版,此镜像已经是Asia/Shanghai时区
不映射配置文件也可以,启动完成进入容器修改配置文件,重启即可
开启鉴权:https://nacos.io/zh-cn/docs/auth.html
方法1: 启动时传入变量NACOS_AUTH_ENABLE=true
方法2: application.properties文件添加nacos.core.auth.enabled=true
1
| sudo docker run -d --name mynacos -e MODE=standalone -e NACOS_AUTH_ENABLE=true --network=host --restart=always -v /data/mynacos/conf/application.properties:/home/nacos/conf/application.properties nacos/nacos-server
|
PostgreSQL
1
| sudo docker run -d -e TZ='Asia/Shanghai' --shm-size 1g --network host -v /data/postgres12:/var/lib/postgresql/data -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres --restart always --name postgres12 postgres:12-alpine
|
RabbitMQ
此镜像默认没有安装tzdata
包
默认用户名密码:guest/guest
1
| sudo docker run -d --name rabbitmq --restart always -p 15672:15672 -p 5672:5672 rabbitmq:3.8-management-alpine
|
也可以指定用户名和密码
1
| sudo docker run -d --name rabbitmq --restart always -p 15672:15672 -p 5672:5672 -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password rabbitmq:3.8-management-alpine
|
PHP-FPM
此镜像默认没有安装tzdata
包
1
| sudo docker run --name php74-fpm --restart always -p 9001:9000 -v /srv/www/www.abc.com:/srv/www/www.abc.com -d php:7.4-fpm-alpine
|
安装php模块
1
2
| sudo docker exec php74-fpm php -m
sudo docker exec php74-fpm docker-php-ext-install pdo_mysql
|
docker-php-ext-install无法安装的模块,试试用pecl安装,进入容器执行更方便
1
2
3
| pecl search XXX
pecl install XXX
docker-php-ext-enable XXX
|
禅道
镜像已经设置过TZ变量为Asia/Shanghai
1
| sudo docker run -d --name zentao -p 8080:80 -v /data/zentao/zentaopms:/www/zentaopms -v /data/zentao/mysql:/var/lib/mysql --restart=always easysoft/zentao:12.5.3
|
Redmine
1
| sudo docker network create redmine-net
|
1
| sudo docker run -d -e TZ='Asia/Shanghai' --network redmine-net -v /data/redmine-postgres:/var/lib/postgresql/data -e POSTGRES_PASSWORD=secret -e POSTGRES_USER=redmine --restart always --name redmine-postgres postgres:alpine
|
默认帐号密码:admin/admin
1
| sudo docker run -d -e TZ='Asia/Shanghai' --restart always --name redmine --network redmine-net -p 3000:3000 -v /data/redmine:/usr/src/redmine/files --link redmine-postgres:postgres redmine:alpine
|