docker-compose 常用yaml 文件 配置

java

version: "3.6"
services:
  dev-11100:
    image: java:8u111-jdk
    container_name: dev-11100
    ports:
      - 11100:8088
      - 21100:5555
    restart: always
    working_dir: /opt/app
    volumes:
      - ../app:/opt/app
      - /etc/localtime:/etc/localtime:ro
    command: java -Duser.timezone=GMT+08 -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5555 -Xms256M -Xmx512M web.jar --spring.profiles.active=dev

mysql

version: "3.6"
services:
  database:
    image: mysql:5.7.22
    container_name: database
    ports:
      - 3306:3306
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=root
    volumes:
      - ../datadir:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro

nginx

version: "3.6"
services:
  nginx:
    image: nginx:1.15.7
    container_name: nginx
    ports:
      - 80:80
      - 443:443
    restart: always
    volumes:
      - ../data/static:/usr/share/nginx/static
      - ../data/conf/nginx.conf:/etc/nginx/nginx.conf
      - ../data/conf.d:/etc/nginx/conf.d
      - ../data/logs:/var/log/nginx
      - ../data/cert:/etc/nginx/cert
      - /etc/localtime:/etc/localtime:ro

nginx 配置文件 conf/nginx.conf 

#user  nobody;
worker_processes  4;
 
events {
        worker_connections  1024;
}
 
http {
        include                 mime.types;
        default_type            application/octet-stream;
        client_max_body_size    20m;
        sendfile                on;
        keepalive_timeout       0;
        gzip                    on;   
        include     conf.d/*.conf;
}

conf.d/xxx.conf 

upstream xxx_web {
    server 192.168.1.15:3000 weight=1;
}
 
server {
    listen 80;
    server_name dev.xxx.cn;
    client_max_body_size 200m;
    
    location /dist/ {
        root /usr/share/nginx/static/dev;
    }
 
    location /xxx {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://xxx_web/;
    }
}

gitlab-ce

version: "3.6"
services:
  gitlab-ce:
    image: gitlab/gitlab-ce:12.0.2-ce.0
    container_name: gitlab-ce
    hostname: 192.168.1.15
    ports:
     - "8086:80"
     - "8087:443"
     - "8088:22"
    restart: always
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        #external_url 'https://192.168.1.15:8087'
        gitlab_rails['lfs_enabled'] = true
        gitlab_rails['backup_keep_time'] = 604800
        gitlab_rails['gitlab_shell_ssh_port'] = 8088
    volumes:
     - /etc/localtime:/etc/localtime:ro
     - ../datadir/gitlab/config:/etc/gitlab
     - ../datadir/gitlab/logs:/var/log/gitlab
     - ../datadir/gitlab/data:/var/opt/gitlab

jenkins

version: "3.6"
services:
  jenkins:
    image: jenkins/jenkins:2.181
    container_name: jenkins
    user: root
    ports:
     - "8080:8080"
     - "50000:50000"
    restart: always
    volumes:
     - /var/run/docker.sock:/var/run/docker.sock
     - ../software:/opt/software
     - /usr/bin/docker:/usr/bin/docker:ro
     - ../jenkins_home:/var/jenkins_home
     - /etc/localtime:/etc/localtime:ro

fastdfs

version: '3.6'
 
services:
  tracker:
    image: morunchang/fastdfs 
    restart: always
    container_name: tracker
    privileged: true
    # 网络模式为host,即直接使用主机的网络接口
    network_mode: "host"
    command: /bin/sh tracker.sh
  storage:
    image: morunchang/fastdfs 
    restart: always
    container_name: storage
    environment:
     - TRACKER_IP=192.168.1.15:22122
     - GROUP_NAME=storagegroup
    volumes:
    # 将本地目录映射到docker容器内的fastdfs数据存储目录,将fastdfs文件存储到主机上,以免每次重建docker容器,之前存储的文件就丢失了。
     - ../data/fast_data:/data/fast_data
    # 使docker具有root权限以读写主机上的目录
    privileged: true
    # 网络模式为host,即直接使用主机的网络接口
    network_mode: "host"
    command: /bin/sh storage.sh

 

你可能感兴趣的:(docker-compose 常用yaml 文件 配置)