docker启动软件开发常用组件
大约 4 分钟
docker启动软件开发常用组件
MySQL启动
docker run -d \
--name mysql \
-p 3306:3306 \
-v /opt/software/mysql/conf/my.cnf:/etc/mysql/my.cnf \
-v /opt/software/mysql/logs:/logs \
-v /opt/software/mysql/mysql_db:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
mysql
redis启动
docker run -d \
-p 6379:6379 \
--name redis \
-v /opt/software/redis/data:/data \
-v /opt/software/redis/redis.conf:/etc/redis/redis.conf \
redis
elasticsearch启动
docker run -d \
--name es \
-p 9200:9200 \
-p 9300:9300 \
-v /opt/software/elasticsearch/data:/usr/share/elasticsearch/data \
-v /opt/software/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-e "discovery.type=single-node" \
-e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
--privileged \
elasticsearch
kibana启动
docker run -d \
--name kibana \
-e ELASTICSEARCH_HOSTS=http://es:9200 \
-p 5601:5601 \
kibana:7.13.1
rabbitmq启动
docker run -d \
--name mq \
-e RABBITMQ_DEFAULT_USER=xiaoshuai \
-e RABBITMQ_DEFAULT_PASS=xiaoshuai123 \
-p 5672:5672 \
-p 15672:15672 \
rabbitmq
nacos启动
docker run -d \
-e MODE=standalone \
--name nacos \
--restart=always \
-p 8848:8848 \
nacos/nacos-server:1.2.0
minio启动
docker run -d \
-p 9000:9000 \
-p 9001:9001 \
--name minio \
--restart=always \
-e "MINIO_ACCESS_KEY=minio" \
-e "MINIO_SECRET_KEY=Lhs123123[=].." \
-v /opt/software/minio/data:/data \
-v /opt/software/minio/config:/root/.minio \
minio/minio server /data --console-address ":9001"
nginx启动
在nginx启动之前先创建一个nginx程序用于拷贝文件,在进行-v数据绑定
1、创建一个基础容器
docker run -d -p 80:80 --name test nginx
2、拷贝数据
mkdir /opt/software/nginx
mkdir /opt/software/nginx/conf
mkdir /opt/software/nginx/logs
docker cp test:/etc/nginx /opt/software/nginx
docker cp test:/usr/share/nginx/html /opt/software/nginx/
mv /opt/software/nginx/nginx /opt/software/nginx/conf
3、创建真正的容器
docker run -d \
-p 80:80 \
--name nginx \
-v /opt/software/nginx/conf:/etc/nginx \
-v /opt/software/nginx/logs:/var/log/nginx \
-v /opt/software/nginx/html:/usr/share/nginx/html \
nginx
gogs启动
docker run -d \
-p 10022:22 \
-p 3000:3000 \
--name gogs \
-v /opt/software/gogs:/data \
gogs/gogs:0.12-arm64
mongodb启动
docker run -d \
-p 27017:27017 \
--name mongo \
mongo
sakura frp启动
docker run \
-d \
--restart=on-failure:5 \
--pull=always \
--name=sakura \
-v /opt/software/sakura-frp/my.crt:/run/frpc/example.com.crt:ro \
-v /opt/software/sakura-frp/my.key:/run/frpc/example.com.key:ro \
natfrp/frpc \
-f awyj941qhahonzecszuf6jczpqk1ckb3:11496797,11496820
postgres 启动
docker run \
--name postgres \
-e POSTGRES_PASSWORD=123456 \
-e ALLOW_IP_RANGE=0.0.0.0/0 \
-p 5432:5432 \
-v /opt/software/postgres:/var/lib/postgresql/data \
-d postgres
RocketMQ 启动
docker run -d \
--restart=always \
--name rmqnamesrv \
-p 9876:9876 \
-v /opt/software/rocketmq/namesrv/logs:/root/logs \
-v /opt/software/rocketmq/namesrv/store:/root/store \
-e "MAX_POSSIBLE_HEAP=1073741824" \
rocketmqinc/rocketmq sh mqnamesrv
mkdir /opt/software/rocketmq/broker/conf
cd /opt/software/rocketmq/broker/conf vim broker.conf
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 所属集群名字
brokerClusterName=DefaultCluster
# broker 名字,注意此处不同的配置文件填写的不一样,如果在 broker-a.properties 使用: broker-a,
# 在 broker-b.properties 使用: broker-b
brokerName=broker-a
# 0 表示 Master,> 0 表示 Slave
brokerId=0
# nameServer地址,分号分割
namesrvAddr=127.0.0.1:9876
# 启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed
# 解决方式1 加上一句 producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP
#producer.setVipChannelEnabled=false
brokerIP1=127.0.0.1
# 在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
# 是否允许 Broker 自动创建 Topic,建议线下开启,线上关闭 !!!这里仔细看是 false,false,false
autoCreateTopicEnable=true
# 是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
# Broker 对外服务的监听端口
listenPort=10911
# 删除文件时间点,默认凌晨4点
deleteWhen=04
# 文件保留时间,默认48小时
fileReservedTime=120
# commitLog 每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
# ConsumeQueue 每个文件默认存 30W 条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
# destroyMapedFileIntervalForcibly=120000
# redeleteHangedFileInterval=120000
# 检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
# 存储路径
# storePathRootDir=/home/ztztdata/rocketmq-all-4.1.0-incubating/store
# commitLog 存储路径
# storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog
# 消费队列存储
# storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue
# 消息索引存储路径
# storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index
# checkpoint 文件存储路径
# storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint
# abort 文件存储路径
# abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort
# 限制的消息大小
maxMessageSize=65536
# flushCommitLogLeastPages=4
# flushConsumeQueueLeastPages=2
# flushCommitLogThoroughInterval=10000
# flushConsumeQueueThoroughInterval=60000
# Broker 的角色
# - ASYNC_MASTER 异步复制Master
# - SYNC_MASTER 同步双写Master
# - SLAVE
brokerRole=ASYNC_MASTER
# 刷盘方式
# - ASYNC_FLUSH 异步刷盘
# - SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
# 发消息线程池数量
# sendMessageThreadPoolNums=128
# 拉消息线程池数量
# pullMessageThreadPoolNums=128
docker run -d \
--restart=always \
--name rmqbroker \
--link rmqnamesrv:namesrv \
-p 10911:10911 \
-p 10909:10909 \
-v /opt/software/rocketmq/broker/logs:/root/logs \
-v /opt/software/rocketmq/broker/store:/root/store \
-v /opt/software/rocketmq/broker/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf \
-e "NAMESRV_ADDR=namesrv:9876" \
-e "MAX_POSSIBLE_HEAP=1073741824" \
rocketmqinc/rocketmq sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker.conf
docker run -d \
--restart=always \
--name rmqadmin \
-e "JAVA_OPTS=-Drocketmq.namesrv.addr=127.0.0.1:9876 -Dcom.rocketmqsendMessageWithVIPChannel=false" \
-p 9999:8080 \
pangliang/rocketmq-console-ng