使用docker-compose安装一些常用软件
Mysql
docker-compose.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| version: '2' services: mysql-service: restart: always image: mysql:8.0.15 container_name: mysql ports: - 3307:3306 environment: TZ: Asia/Shanghai MYSQL_ROOT_PASSWORD: Xc58525456 command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --explicit_defaults_for_timestamp=true --lower_case_table_names=1 volumes: - /usr/local/docker/mysql/data:/var/lib/mysql
|
nginx
docker-compose.yaml
1 2 3 4 5 6 7 8 9 10 11
| version: '2' services: nginx: restart: always image: nginx container_name: nginx ports: - 80:80 volumes: - ./conf/nginx.conf:/etc/nginx/nginx.conf - ./wwwroot:/usr/share/nginx/wwwroot
|
nginx.conf
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| worker_processes 1;
events { worker_connections 1024; }
http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; charset utf-8;
server { listen 80; server_name 192.168.56.10; access_log logs/pbootcms.access.log; error_log logs/pbootcms.error.log; index index.html index.htm index.php; root /home/www/pbootcms;
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php/$1 last; break; } }
location ~ [^/]\.php(/|$) { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include /etc/nginx/fastcgi.conf; fastcgi_split_path_info ^(.+?\.php)(/.*)$; set $path_info $fastcgi_path_info; fastcgi_param PATH_INFO $path_info; fastcgi_param CI_ENV 'development'; try_files $fastcgi_script_name =404; }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 7d; access_log off; } location ~ /\.ht { deny all; } } }
|
minio
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
| version: '3.1' services: minio: image: minio/minio container_name: minio restart: always ports: - 9001:9000 - 8000:8000 command: server --address '0.0.0.0:9000' --console-address "0.0.0.0:8000" /data logging: options: max-size: "50M" max-file: "10" driver: json-file environment: MINIO_ACCESS_KEY: minio MINIO_SECRET_KEY: minio123 volumes: - ./data:/data - ./config:/root/.minio/ healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9001/minio/health/live"] interval: 30s timeout: 20s retries: 3
|
elastic-kibana
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| version: '2.2' services: cerebro: image: lmenezes/cerebro:0.8.3 container_name: cerebro ports: - "5701:9000" command: - -Dhosts.0.host=http://elasticsearch:9200 networks: - es7net kibana: image: docker.elastic.co/kibana/kibana:7.1.0 container_name: kibana7 environment: - I18N_LOCALE=zh-CN - XPACK_GRAPH_ENABLED=true - TIMELION_ENABLED=true - XPACK_MONITORING_COLLECTION_ENABLED="true" - ELASTICSEARCH_USERNAME=kibana - ELASTICSEARCH_PASSWORD=demo_password ports: - "5601:5601" networks: - es7net elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:7.1.0 container_name: es7_01 environment: - cluster.name=test-es - node.name=es7_01 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - "TZ=Asia/Shanghai" - discovery.type=single-node - path.data=node0_data - xpack.security.enabled=true - xpack.security.transport.ssl.enabled=false ulimits: memlock: soft: -1 hard: -1 privileged: true volumes: - /data/es7data1:/usr/share/elasticsearch/data ports: - 9200:9200 networks: - es7net
networks: es7net: driver: bridge
|
portainer
1 2 3 4 5 6 7 8
| portainer: image: portainer/portainer restart: always ports: - "9000:9000" volumes: - /var/run/docker.sock:/var/run/docker.sock - /data/docker/portainer/data:/data
|
confluence
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
| version: '2' services: confluence-mysql: image: postgres:9.4 container_name: confluence-db ports: - "5432:5432" restart: always environment: POSTGRES_PASSWORD: pg123456. volumes: - /usr/local/confluence/pgsql-data:/var/lib/postgresql/data confluence: image: cptactionhank/atlassian-confluence:7.2.0 container_name: confluence volumes: - "/home/confluence/apps/confluence:/opt/atlassian/confluence" - "/home/confluence/data:/var/atlassian/confluence" - "/usr/share/zoneinfo/Asia/Shanghai:/etc/localtime" restart: always user: root ports: - "8090:8090" environment: JAVA_OPTS: -Duser.timezone=Asia/Shanghai CATALINA_OPTS: -Xms256m -Xmx2g depends_on: - confluence-mysql
|
redis
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| version: '2' services: master: image: redis container_name: redis-master ports: - 6379:6379 restart: always slave1: image: redis container_name: redis-slave-1 ports: - 6380:6379 command: redis-server --slaveof redis-master 6379
slave2: image: redis container_name: redis-slave-2 ports: - 6381:6379 command: redis-server --slaveof redis-master 6379
|
wordpress
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
| version: '3.3'
services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress
wordpress: depends_on: - db image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_NAME: wordpress volumes: db_data: {}
|
zookeeper
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 38 39 40 41 42 43 44 45
| version: '2'
services: zoo1: image: zookeeper:3.4.11 restart: always hostname: zoo1 container_name: zookeeper_1 ports: - 2181:2181 volumes: - /usr/local/docker_app/zookeeper/zoo1/data:/data - /usr/local/docker_app/zookeeper/zoo1/datalog:/datalog environment: ZOO_MY_ID: 1 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo2: image: zookeeper:3.4.11 restart: always hostname: zoo2 container_name: zookeeper_2 ports: - 2182:2181 volumes: - /usr/local/docker_app/zookeeper/zoo2/data:/data - /usr/local/docker_app/zookeeper/zoo2/datalog:/datalog environment: ZOO_MY_ID: 2 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo3: image: zookeeper:3.4.11 restart: always hostname: zoo3 container_name: zookeeper_3 ports: - 2183:2181 volumes: - /usr/local/docker_app/zookeeper/zoo3/data:/data - /usr/local/docker_app/zookeeper/zoo3/datalog:/datalog environment: ZOO_MY_ID: 3 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
|
yapi
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 38
| version: '3.1'
services: mongo: image: mongo:4 restart: always environment: MONGO_INITDB_ROOT_USERNAME: root MONGO_INITDB_ROOT_PASSWORD: Xc58525456 MONGO_INITDB_DATABASE: yapi volumes: - ./mongo-conf:/docker-entrypoint-initdb.d - ./mongo/etc:/etc/mongo - ./mongo/data/db:/data/db ports: - 27017:27017 healthcheck: test: ["CMD", "netstat -anp | grep 27017"] interval: 2m timeout: 10s retries: 3 yapi: build: context: ./ dockerfile: Dockerfile image: yapi command: "node /my-yapi/vendors/server/app.js" volumes: - ./my-yapi:/my-yapi ports: - 9090:9090 - 3000:3000 depends_on: - mongo
|
mongo-confi=====init-mongo.js
1 2 3 4 5 6 7 8 9 10 11 12
| db.createUser({ user: 'admin', pwd: 'admin123456', roles: [ { role: "root", db: "admin" } ] });
db.auth("admin", "admin123456"); db.createUser({ user: 'yapi', pwd: 'yapi123456', roles: [ { role: "dbAdmin", db: "yapi" }, { role: "readWrite", db: "yapi" } ]
});
|
Dockerfile
1 2 3 4 5 6
| FROM node:12-alpine COPY repositories /etc/apk/repositories
RUN npm install -g yapi-cli --registry https://registry.npm.taobao.org
EXPOSE 3000 9090
|
repositories
1 2 3
| https://mirrors.aliyun.com/alpine/v3.6/main/
https://mirrors.aliyun.com/alpine/v3.6/community/
|
readme
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| YApi Docker镜像 ==============
YApi: https://github.com/YMFE/yapi/releases
制作本地的yapi docker镜像, docker-compose一键维护和部署.
## How
1. 初始化db, 开启自定义配置
``` git clone https://github.com/Ryan-Miao/docker-yapi.git cd docker-yapi docker-compose up ```
打开 localhost:9090
- 默认部署路径为`/my-yapi`(需要修改docker-compose.yml才可以更改) - 修改管理员邮箱 `ryan.miao@demo.com` (随意, 修改为自己的邮箱) - 修改数据库地址为 `mongo` 或者修改为自己的mongo实例 (docker-compose配置的mongo服务名称叫mongo) - 打开数据库认证 - 输入数据库用户名: `yapi`(mongo配置的用户名, 见mongo-conf/init-mongo.js) - 输入密码: `yapi123456`(mongo配置的密码, 见mongo-conf/init-mongo.js)
点击开始部署.
![](doc/init.jpg) ![](doc/init-2.jpg)
2. 部署完毕后, 修改docker-compose.yml 启用
``` yapi: build: context: ./ dockerfile: Dockerfile image: yapi # 第一次启动使用 # command: "yapi server" # 之后使用下面的命令 command: "node /my-yapi/vendors/server/app.js" ```
重启服务:
``` docker-compose up ```
访问 localhost:3000
- 输入用户名ryan.miao@demo.com(自己输入的管理员邮箱) - 输入密码ymfe.org(默认的初始化密码, 之后可以修改)
然后可以导入一个swagger的接口数据试试:
![](doc/start-1.jpg) ![](doc/start-2.jpg)
3. 后台启动
前台启动确认没问题后, 直接
|