fastDFS
version: '3.1' services: fastdfs: build: environment restart: always container_name: fastdfs volumes: - ./storage:/fastdfs/storage network_mode: host
Spring Cloud Config
version: '3.1' services: itoken-config: restart: always image: IP地址:端口/itoken-config container_name: itoken-config ports: - 8888:8888
- Dockerfile文件內(nèi)容
FROM openjdk:8-jre RUN mkdir /app COPY itoken-config-1.0.0-SNAPSHOT.jar /app/ CMD java -jar /app/itoken-config-1.0.0-SNAPSHOT.jar --spring.profiles.active=prod EXPOSE 8888
MySQL
需要在
docker-compose.yml同級(jí)目錄分別建立3個(gè)文件夾
conf配置data數(shù)據(jù)logs日志version: '3.1' services: mysql: restart: always image: mysql:5.7.22 container_name: itoken_database ports: - 3306:3306 environment: TZ: Asia/Shanghai MYSQL_ROOT_PASSWORD: 123456 command: --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --explicit_defaults_for_timestamp=true --lower_case_table_names=1 --max_allowed_packet=128M --sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO" volumes: - mysql-data:/var/lib/mysql volumes: mysql-data:
Nginx
需要在
docker-compose.yml同級(jí)目錄分別建立2個(gè)文件夾
conf配置wwwroot頁面version: '3.1' services: nginx: restart: always image: ip:port/nginx container_name: nginx ports: - 81:80 # 端口映射根據(jù)需求設(shè)置 - 9000:9000 volumes: - ./conf/nginx.conf:/etc/nginx/nginx.conf - ./wwwroot:/usr/share/nginx/wwwroot以下是Nginx不帶注釋的配置
nginx.confworker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name 192.168.231.129; location / { # Nginx解決瀏覽器跨域問題 add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers X-Requested-With; add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS; root /usr/share/nginx/wwwroot/cdn; index index.html index.htm; } } }以下是Nginx帶注釋的配置
nginx.conf# CPU內(nèi)核數(shù)量 worker_processes 1; # 每個(gè)內(nèi)核處理多少個(gè)連接 events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; # 配置虛擬主機(jī) 192.168.231.129 server { # 監(jiān)聽的ip和端口,配置 >192.168.231.129:80 listen 80; # 虛擬主機(jī)名稱這里配置ip地址 # server_name 192.168.231.129; server_name daxian.com; # 所有的請(qǐng)求都以 / 開始,所有的請(qǐng)求都可以匹配此 location location / { # 使用 root 指令指定虛擬主機(jī)目錄即網(wǎng)頁存放目錄 # 比如訪問 http://ip/index.html 將找到 /usr/local/docker/nginx/wwwroot/html80/index.html # 比如訪問 http://ip/item/index.html 將找到 /usr/local/docker/nginx/wwwroot/html80/item/index.html root /usr/share/nginx/wwwroot/html81; # 指定歡迎頁面,按從左到右順序查找 index index.html index.htm; } } # 配置虛擬主機(jī) 192.168.231.129 每開一個(gè)虛擬主機(jī)就是開一個(gè)server server { listen 9000; server_name 192.168.231.129; location / { root /usr/share/nginx/wwwroot/html9000; index index.html index.htm; } } }以下是Nginx帶負(fù)載均衡的配置
nginx.conf# nginx負(fù)載均衡配置 user nginx; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream myapp1 { server 192.168.231.129:9090 weight=10; server 192.168.231.129:9091 weight=10; } server { listen 80; server_name 192.168.231.129; location / { proxy_pass http://myapp1; index index.jsp index.html index.htm; } } }
Redis
version: '3.1' services: master: image: redis restart: always container_name: redis-master ports: - 6379:6379 slave1: image: redis restart: always container_name: redis-slave-1 ports: - 6380:6379 command: redis-server --slaveof redis-master 6379 slave2: image: redis restart: always container_name: redis-slave-2 ports: - 6381:6379 command: redis-server --slaveof redis-master 6379Redis Sentinel
需要
docker-compose.yml同級(jí)目錄建立三個(gè)配置文件,文件名分別為sentinel1.conf、sentinel2.conf、sentinel3.conf
sentinel.conf內(nèi)容為(根據(jù)這份文件復(fù)制3份conf)port 26379 dir /tmp # 自定義集群名,其中 127.0.0.1 為 redis-master 的 ip,6379 為 redis-master 的端口,2 為最小投票數(shù)(因?yàn)橛?3 臺(tái) Sentinel 所以可以設(shè)置成 2) sentinel monitor mymaster 192.168.231.129 6379 2 sentinel down-after-milliseconds mymaster 30000 sentinel parallel-syncs mymaster 1 sentinel failover-timeout mymaster 180000 sentinel deny-scripts-reconfig yes
docker-compose.yml內(nèi)容為version: '3.1' services: sentinel1: image: redis container_name: redis-sentinel-1 ports: - 26379:26379 command: redis-sentinel /usr/local/etc/redis/sentinel.conf volumes: - ./sentinel1.conf:/usr/local/etc/redis/sentinel.conf sentinel2: image: redis container_name: redis-sentinel-2 ports: - 26380:26379 command: redis-sentinel /usr/local/etc/redis/sentinel.conf volumes: - ./sentinel2.conf:/usr/local/etc/redis/sentinel.conf sentinel3: image: redis container_name: redis-sentinel-3 ports: - 26381:26379 command: redis-sentinel /usr/local/etc/redis/sentinel.conf volumes: - ./sentinel3.conf:/usr/local/etc/redis/sentinel.conf
RabbitMQ
需要建立spring-boot-amqp-provider消息隊(duì)列提供者,spring-boot-amqp-consumer消息隊(duì)列消費(fèi)者兩個(gè)項(xiàng)目,并在application.yml設(shè)置連接上RabbitMQversion: '3.1' services: rabbitmq: restart: always image: rabbitmq:management container_name: rabbitmq ports: - 5672:5672 - 15672:15672 environment: TZ: Asia/Shanghai RABBITMQ_DEFAULT_USER: rabbit RABBITMQ_DEFAULT_PASS: 123456 volumes: - ./data:/var/lib/rabbitmq
Nexus ( Maven私有倉庫 )
需要docker-compose.yml同級(jí)目錄建立一個(gè)data文件夾用于存放數(shù)據(jù)version: '3.1' services: nexus: restart: always image: sonatype/nexus3 container_name: nexus ports: - 8081:8081 volumes: - /usr/local/docker/nexus/data:/nexus-data
Registry( Docker私有鏡像倉庫 )
需要docker-compose.yml同級(jí)目錄建立兩個(gè)文件夾,分別為certs和dataversion: '3.1' services: # registry服務(wù) registry: image: registry restart: always container_name: registry ports: - 5000:5000 volumes: - /usr/local/docker/registry/data:/var/lib/registry # 前端頁面 frontend: image: konradkleine/docker-registry-frontend:v2 restart: always ports: - 8080:80 volumes: - ./certs/frontend.crt:/etc/apache2/server.crt:ro - ./certs/frontend.key:/etc/apache2/server.key:ro environment: - ENV_DOCKER_REGISTRY_HOST=192.168.231.129 - ENV_DOCKER_REGISTRY_PORT=5000