基础环境准备
基础信息
- docker通讯底层基于iptables,firewalld也是对iptables的封装
- docker-compose是单击容器编排工具
- docker-swarm跨机器进行容器编排,docker内置
- kubernetes 用于大量容器编排工具
docker安装
- linux docker 安装
docker快速构建应用
mysql
docker run -p3306:3306 --name mysql -v /home/docker/mysql/conf:/etc/mysql -v /home/docker/mysql/logs:/logs -v /home/docker/mysql/data:/var/lib/mysql -eMYSQL_ROOT_PASSWORD=12ncqOwTCGyg7tYbr34 -d mysql:5.7
- 映射外网端口:3306
- 容器名字: mysql
- 宿主机持久化、日志、配置文件目录:/home/docker
- 版本: 5.7
- 默认的root密码: 12ncqOwTCGyg7tYbr34
postgre
docker run -p5432:5432 -v /home/docker/postgresql/data:/var/lib/postgresql/data -ePOSTGRES_PASSWORD=123456-eTZ=PRC --name=postgres postgres
- 映射外网端口:5432
- 容器名字: postgres
- 宿主机持久化目录:/home/docker/postgresql/data
- 默认的root密码: 123456
nacos
docker run --envMODE=standalone --name nacos -d-p8848:8848 nacos/nacos-server
- 映射外网端口:8848
- 容器名字: nacos
- 模式为单机启动:MODE
gogs
docker run -d-p10022:22 -p10080:3000 --name=gogs -v /home/gogs/data/:/data gogs/gogs
- 映射外网端口:10080
- 容器名字: nacos
- 模式为单机启动:MODE
sentinel
docker run --name sentinel -d-p8858:8858 -d bladex/sentinel-dashboard
- 映射外网端口:8858
- 容器名字: sentinel
zipkin
docker run -d--restart always -p9411:9411 --name zipkin openzipkin/zipkin
- 映射外网端口:9411
- 容器名字: zipkin
jenkins
docker run -d\--restart always \--name jenkins \-u root \-p5892:8080 \-v /home/docker/jenkins/jenkins-data:/var/jenkins_home \-v /home/docker/jenkins/docker.sock:/var/run/docker.sock \-v /home/docker/jenkins:/home \
jenkinsci/blueocean
- 映射外网端口:5892
- 容器名字: jenkins
- 宿主机持久化目录:/home/docker/jenkins
nginx
docker run -d-p8100:80 \--name nginx \-v /home/nginx/html:/usr/share/nginx/html \-v /home/nginx/nginx.conf:/etc/nginx/nginx.conf \-v /home/nginx/logs:/var/log/nginx \-v /home/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf \--privileged=true \
nginx
- 映射外网端口:8100
- 容器名字: nginx
- 宿主机持久化目录:/home/nginx
rancher
docker run -d-v /home/docker/rancher/mysql-data/mysql:/var/lib/mysql --restart=unless-stopped -p5652:8080 rancher/server
- 映射外网端口:5652
redis
docker run -p6379:6379 --name redis -v /home/redis/redis.conf:/etc/redis/redis.conf -v /home/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonlyyes--requirepass123456
- 映射外网端口:6379
- 容器名字: redis
- 宿主机持久化目录:/home/redis
- redis密码:123456
portainer
docker run -d-p9000:9000 \--restart=always \-v /var/run/docker.sock:/var/run/docker.sock \--name portainer portainer/portainer
- 映射外网端口:9000
- 容器名字: portainer
rocketMQ
nameServer
docker run -d\--name rmqnamesrv \-p19876:9876 \-v /home/docker/rocketmq/data/namesrv/logs:/root/logs \-v /home/docker/rocketmq/data/namesrv/store:/root/store \-e"JAVA_OPTS=-Duser.home=/opt"\-e"JAVA_OPT_EXT=-server -Xms1024m -Xmx1024m"\
rocketmqinc/rocketmq sh mqnamesrv
- 映射外网端口:19876
- 容器名字: rmqnamesrv
- 宿主机持久化目录:/home/docker/rocketmq/data
broker服务器
docker run -d\--name rmqbroker \-v /home/docker/rocketmq/data/broker/logs:/root/logs \-v /home/docker/rocketmq/data/broker/store:/root/store \-v /home/docker/rocketmq/data/conf/broker.conf:/opt/rocketmq/conf/broker.conf \--link rmqnamesrv:namesrv -e"NAMESRV_ADDR=IP:19876"\-e"JAVA_OPTS=-Duser.home=/opt"\-e"JAVA_OPT_EXT=-server -Xms1024m -Xmx1024m"\
rocketmqinc/rocketmq sh mqbroker -c /home/docker/rocketmq/broker/broker.conf
- 映射外网端口:10911
- 容器名字: rmqbroker
- 宿主机持久化目录:/home/docker/rocketmq/data/broker
- NAMESRV_ADDR=IP:19876 当前的rmqnamesrv IP及端口
界面控制台
docker run -d\-e"JAVA_OPTS=-Drocketmq.config.namesrvAddr=IP:19876 -Drocketmq.config.isVIPChannel=false"\-p9993:8080 -t styletang/rocketmq-console-ng
- 映射外网端口:9993
- namesrvAddr=IP:19876 当前的rmqnamesrv IP及端口
rocketMQ docker-compose启动
version: '3.5'
services:
rmqnamesrv:
image: rocketmqinc/rocketmq-namesrv
container_name: rmqnamesrv
ports:
- 19876:9876
volumes:
- /home/docker/rocketmq/namesrv/logs:/opt/logs
- /home/docker/rocketmq/namesrv/store:/opt/store
rmqbroker:
image: rocketmqinc/rocketmq-broker
container_name: rmqbroker
ports:
- 10909:10909
- 10911:10911
volumes:
- /home/docker/rocketmq/broker/logs:/opt/logs
- /home/docker/rocketmq/broker/store:/opt/store
- /home/docker/rocketmq/broker/broker.conf:/etc/rocketmq/broker.conf
environment:
NAMESRV_ADDR: "192.168.0.37:19876"
JAVA_OPTS: " -Duser.home=/opt"
JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
command: mqbroker -c /home/docker/rocketmq/broker/broker.conf
depends_on:
- rmqnamesrv
rmqconsole:
image: styletang/rocketmq-console-ng
container_name: rmqconsole
ports:
- 7799:8080
environment:
JAVA_OPTS: "-Drocketmq.namesrv.addr=192.168.0.37:19876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
depends_on:
- rmqnamesrv
xxl-job
docker run -d\-ePARAMS="--spring.datasource.url=jdbc:mysql://192.168.0.37:3307/xxl_job?Unicode=true&characterEncoding=UTF-8 --spring.datasource.username=root --spring.datasource.password=123456 --xxl.job.accessToken=a984ddf0-ce9d-40a2-84d3-3ffba0d21ee0"\-eJAVA_OPTS="-Xms512m -Xmx512m"\-p7777:8080 \-v /home/docker/xxllog:/data/applogs \--name xxl-job-admin xuxueli/xxl-job-admin:2.3.0
- 映射外网端口:7777
- 容器名字: xxl-job-admin
- 宿主机持久化目录:/home/docker/rocketmq/data/broker
- -e PARAMS 配置JDBC信息
netdata
docker run -d--name=netdata \-p19999:19999 \-v /home/docker/netdata/netdataconfig:/etc/netdata \-v /home/docker/netdata/netdatalib:/var/lib/netdata \-v /home/docker/netdata/netdatacache:/var/cache/netdata \-v /home/docker/netdata/etc/passwd:/host/etc/passwd:ro \-v /home/docker/netdata/etc/group:/host/etc/group:ro \-v /home/docker/netdata/proc:/host/proc:ro \-v /home/docker/netdata/sys:/host/sys:ro \-v /home/docker/netdata/etc/os-release:/host/etc/os-release:ro \--restart unless-stopped \
--cap-add SYS_PTRACE \
--security-opt apparmor=unconfined \
netdata/netdata
activemq
docker run --name='activemq'\-itd\-p8161:8161 \-p61616:61616 \-eACTIVEMQ_ADMIN_LOGIN=admin \-eACTIVEMQ_ADMIN_PASSWORD=123456\--restart=always \-v /usr/soft/activemq:/data/activemq \-v /usr/soft/activemq/log:/var/log/activemq \
webcenter/activemq:latest
扩展知识
- kubeadm搭建k8s集群
- docker常用命令总结大全
- 到底什么是云原生?下一个内卷
本文转载自: https://blog.csdn.net/u010800804/article/details/126970397
版权归原作者 rundreamsFly 所有, 如有侵权,请联系我们删除。
版权归原作者 rundreamsFly 所有, 如有侵权,请联系我们删除。