当前位置:   article > 正文

【云原生-Docker】快速搭建日常应用部署_docker要依赖iptables吗

docker要依赖iptables吗

基础环境准备

基础信息

  • docker通讯底层基于iptables,firewalld也是对iptables的封装
  • docker-compose是单击容器编排工具
  • docker-swarm跨机器进行容器编排,docker内置
  • kubernetes 用于大量容器编排工具

docker安装

docker快速构建应用

mysql

docker run -p 3306:3306 --name mysql -v /home/docker/mysql/conf:/etc/mysql -v /home/docker/mysql/logs:/logs -v /home/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=12ncqOwTCGyg7tYbr34 -d mysql:5.7
  • 1
  • 映射外网端口:3306
  • 容器名字: mysql
  • 宿主机持久化、日志、配置文件目录:/home/docker
  • 版本: 5.7
  • 默认的root密码: 12ncqOwTCGyg7tYbr34

mysql8.0

docker run \
--name mysql \
--restart always \
-p 3306:3306 \
-v /home/docker/mysql/conf/my.cnf:/etc/mysql/my.cnf \
-v /home/docker/mysql/data:/var/lib/mysql \
-v /home/docker/mysql/logs:/logs \
-e MYSQL_ROOT_PASSWORD=12345678 \
-d mysql:8.0.31
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

postgre

docker run -p 5432:5432 -v /home/docker/postgresql/data:/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 -e TZ=PRC --name=postgres postgres
  • 1
  • 映射外网端口:5432
  • 容器名字: postgres
  • 宿主机持久化目录:/home/docker/postgresql/data
  • 默认的root密码: 123456

nacos

docker run --env MODE=standalone --name nacos -d -p 8848:8848 nacos/nacos-server
  • 1
  • 映射外网端口:8848
  • 容器名字: nacos
  • 模式为单机启动:MODE

gogs

docker run -d -p 10022:22 -p 10080:3000 --name=gogs -v /home/gogs/data/:/data gogs/gogs
  • 1
  • 映射外网端口:10080
  • 容器名字: nacos
  • 模式为单机启动:MODE

sentinel

docker run --name sentinel -d -p 8858:8858 -d bladex/sentinel-dashboard
  • 1
  • 映射外网端口:8858
  • 容器名字: sentinel

zipkin

docker run -d --restart always -p 9411:9411 --name zipkin openzipkin/zipkin
  • 1
  • 映射外网端口:9411
  • 容器名字: zipkin

jenkins

docker run -d \
  --restart always \
  --name jenkins \
  -u root \
  -p 5892: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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 映射外网端口:5892
  • 容器名字: jenkins
  • 宿主机持久化目录:/home/docker/jenkins

nginx

docker run -d -p 8100: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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 映射外网端口:8100
  • 容器名字: nginx
  • 宿主机持久化目录:/home/nginx

rancher

docker run -d -v /home/docker/rancher/mysql-data/mysql:/var/lib/mysql --restart=unless-stopped -p 5652:8080 rancher/server
  • 1
  • 映射外网端口:5652

redis

mkdir -p /home/docker/redis/data
mkdir -p /home/docker/redis/conf
sudo touch /home/docker/redis/conf/redis.conf

#bind 127.0.0.1
protected-mode no
appendonly yes
requirepass 12345678

docker run --name redis -p 6379:6379 \
-v /home/docker/redis/data:/data \
-v /home/docker/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 映射外网端口:6379
  • 容器名字: redis
  • 宿主机持久化目录:/home/docker/redis
  • redis密码:12345678

portainer

docker run -d -p 9000:9000 \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
--name portainer portainer/portainer
  • 1
  • 2
  • 3
  • 4
  • 映射外网端口:9000
  • 容器名字: portainer

rocketMQ

nameServer
docker run -d \
--name rmqnamesrv \
-p 19876: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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 映射外网端口: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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 映射外网端口: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" \
-p 9993:8080 -t styletang/rocketmq-console-ng
  • 1
  • 2
  • 3
  • 映射外网端口: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
  • 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

xxl-job

docker run -d \
    -e PARAMS="--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" \
    -e JAVA_OPTS="-Xms512m -Xmx512m" \
    -p 7777:8080 \
    -v /home/docker/xxllog:/data/applogs \
    --name xxl-job-admin xuxueli/xxl-job-admin:2.3.0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 映射外网端口:7777
  • 容器名字: xxl-job-admin
  • 宿主机持久化目录:/home/docker/rocketmq/data/broker
  • -e PARAMS 配置JDBC信息

netdata

docker run -d --name=netdata \
  -p 19999: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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

Yearning

docker run -d -it -p8000:8000 -e SECRET_KEY=dbcjqheupqjsuwsm -e MYSQL_USER=root -e MYSQL_ADDR=10.12.3.132:3306 -e MYSQL_PASSWORD=CvRroC7QHPaWxHoeXzP2 -e MYSQL_DB=yearning yeelabs/yearning
  • 1

activemq

docker run --name='activemq' \
      -itd \
      -p 8161:8161 \
      -p 61616:61616 \
      -e ACTIVEMQ_ADMIN_LOGIN=admin \
      -e ACTIVEMQ_ADMIN_PASSWORD=123456 \
      --restart=always \
      -v /usr/soft/activemq:/data/activemq \
      -v /usr/soft/activemq/log:/var/log/activemq \
      webcenter/activemq:latest
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

扩展知识

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/645416
推荐阅读
相关标签
  

闽ICP备14008679号