From 2e4d488295fd122ef7972df6dd61e6550247430c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=A4=A9=E5=9E=9A?= Date: Fri, 15 Dec 2023 16:17:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AF=B4=E6=98=8E=E5=8F=8A?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E6=96=87=E4=BB=B6=EF=BC=9B=E6=9B=B4=E6=96=B0?= =?UTF-8?q?README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 30 +++++++++++++++++-- description/compose.yaml | 50 ++++++++++++++++++++++++++++++++ examples/adminer/compose.yaml | 26 +++++++++++++++++ examples/mariadb/10/compose.yaml | 46 +++++++++++++++++++++++++++++ examples/mariadb/10/my.cnf | 4 +++ examples/mariadb/10/root.key | 1 + examples/mysql/5/compose.yaml | 46 +++++++++++++++++++++++++++++ examples/mysql/5/my.cnf | 4 +++ examples/mysql/5/root.key | 1 + examples/mysql/8/compose.yaml | 46 +++++++++++++++++++++++++++++ examples/mysql/8/my.cnf | 4 +++ examples/mysql/8/root.key | 1 + examples/phpmyadmin/compose.yaml | 28 ++++++++++++++++++ examples/portainer/compose.yaml | 30 +++++++++++++++++++ 14 files changed, 315 insertions(+), 2 deletions(-) create mode 100644 description/compose.yaml create mode 100644 examples/adminer/compose.yaml create mode 100644 examples/mariadb/10/compose.yaml create mode 100644 examples/mariadb/10/my.cnf create mode 100644 examples/mariadb/10/root.key create mode 100644 examples/mysql/5/compose.yaml create mode 100644 examples/mysql/5/my.cnf create mode 100644 examples/mysql/5/root.key create mode 100644 examples/mysql/8/compose.yaml create mode 100644 examples/mysql/8/my.cnf create mode 100644 examples/mysql/8/root.key create mode 100644 examples/phpmyadmin/compose.yaml create mode 100644 examples/portainer/compose.yaml diff --git a/README.md b/README.md index 21fb372..2ef2114 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,29 @@ -# docker-compose +# Docker Compose 示例文件 -Docker Compose 说明及示例 \ No newline at end of file +
+ +## 命令说明 +### 启动 +``` shell +docker-compose up +``` + +### 停止 +``` shell +docker-compose down +``` + +### 重启 +``` shell +docker-compose restart +``` + +
+ +## 服务说明 +### portainer +Portainer Docker 管理器 +官网: https://www.portainer.io +文档: https://docs.portainer.io +### mysql +MySQL 数据库 diff --git a/description/compose.yaml b/description/compose.yaml new file mode 100644 index 0000000..3387510 --- /dev/null +++ b/description/compose.yaml @@ -0,0 +1,50 @@ +version: "3.9" + +services: + ${SERVICE_NAME}: + image: ${IMAGE_NAME}:${IMAGE_TAG} + container_name: ${CONTAINER_NAME} + restart: on-failure:3 + privileged: true + user: ${USER_NAME}:${USER_GROUP} + working_dir: ${WORKING_DIR} + volumes: + - /etc/localtime:/etc/localtime:ro + - ${VOLUME_NAME}:${CONTAINER_PATH} + - ${HOST_PATH}:${CONTAINER_PATH} + configs: + - ${CONFIG_NAME} + secrets: + - ${SECRET_NAME} + environment: + - ${KEY}=${VALUE} + command: ${COMMAND} + depends_on: + - ${SERVICE_NAME} + network_mode: host + ports: + - ${HOST_PORT}:${CONTAINER_PORT} + networks: + - ${NETWORK_NAME} + +volumes: + ${VOLUME_NAME}: + external: true + name: ${VOLUME_NAME} + +configs: + ${CONFIG_NAME}: + external: true + name: ${CONFIG_NAME} + file: ${CONFIG_FILE_NAME} + +secrets: + ${SECRET_NAME}: + external: true + name: ${SECRET_NAME} + file: ${SECRET_FILE_NAME} + +networks: + ${NETWORK_NAME}: + external: true + name: ${NETWORK_NAME} diff --git a/examples/adminer/compose.yaml b/examples/adminer/compose.yaml new file mode 100644 index 0000000..a59772e --- /dev/null +++ b/examples/adminer/compose.yaml @@ -0,0 +1,26 @@ +version: "3.9" + +services: + adminer: + image: adminer:4.8.1 + container_name: adminer + hostname: adminer + restart: always + networks: + - db_network + ports: + - "8080:8080" + volumes: + - /etc/localtime:/etc/localtime:ro + +networks: + db_network: + name: db_network + external: true +# driver: bridge +# driver_opts: +# encrypted: 'true' +# ipam: +# driver: default +# config: +# - subnet: 172.21.0.1/24 diff --git a/examples/mariadb/10/compose.yaml b/examples/mariadb/10/compose.yaml new file mode 100644 index 0000000..e22b7eb --- /dev/null +++ b/examples/mariadb/10/compose.yaml @@ -0,0 +1,46 @@ +version: "3.9" + +services: + mariadb: + image: mariadb:10.11.5 + container_name: mariadb + hostname: mariadb + restart: always + networks: + - db_network + ports: + - "3306:3306" + volumes: + - /etc/localtime:/etc/localtime:ro + - mariadb_db:/var/lib/mysql + configs: + - source: mariadb_conf + target: /etc/mysql/conf.d/my.cnf + mode: 0444 + secrets: + - mariadb_root_key + environment: + - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mariadb_root_key + +volumes: + mariadb_db: + +configs: + mariadb_conf: + file: my.cnf + +secrets: + mariadb_root_key: + file: root.key + +networks: + db_network: + name: db_network + external: true +# driver: bridge +# driver_opts: +# encrypted: 'true' +# ipam: +# driver: default +# config: +# - subnet: 172.21.0.1/24 diff --git a/examples/mariadb/10/my.cnf b/examples/mariadb/10/my.cnf new file mode 100644 index 0000000..ac541ff --- /dev/null +++ b/examples/mariadb/10/my.cnf @@ -0,0 +1,4 @@ +[mysqld] +max_connections = 1000 +character-set-server = utf8mb4 +collation-server = utf8mb4_unicode_ci diff --git a/examples/mariadb/10/root.key b/examples/mariadb/10/root.key new file mode 100644 index 0000000..37ddc91 --- /dev/null +++ b/examples/mariadb/10/root.key @@ -0,0 +1 @@ +5bkyVJsvXuSEZag8xChVXn9GEwHzrmvX diff --git a/examples/mysql/5/compose.yaml b/examples/mysql/5/compose.yaml new file mode 100644 index 0000000..202f678 --- /dev/null +++ b/examples/mysql/5/compose.yaml @@ -0,0 +1,46 @@ +version: "3.9" + +services: + mysql: + image: mysql:5.7.43 + container_name: mysql + hostname: mysql + restart: always + networks: + - db_network + ports: + - "3306:3306" + volumes: + - /etc/localtime:/etc/localtime:ro + - mysql_db:/var/lib/mysql + configs: + - source: mysql_conf + target: /etc/mysql/conf.d/my.cnf + mode: 0444 + secrets: + - mysql_root_key + environment: + - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_key + +volumes: + mysql_db: + +configs: + mysql_conf: + file: my.cnf + +secrets: + mysql_root_key: + file: root.key + +networks: + db_network: + name: db_network + external: true +# driver: bridge +# driver_opts: +# encrypted: 'true' +# ipam: +# driver: default +# config: +# - subnet: 172.21.0.1/24 diff --git a/examples/mysql/5/my.cnf b/examples/mysql/5/my.cnf new file mode 100644 index 0000000..ac541ff --- /dev/null +++ b/examples/mysql/5/my.cnf @@ -0,0 +1,4 @@ +[mysqld] +max_connections = 1000 +character-set-server = utf8mb4 +collation-server = utf8mb4_unicode_ci diff --git a/examples/mysql/5/root.key b/examples/mysql/5/root.key new file mode 100644 index 0000000..5a1bb41 --- /dev/null +++ b/examples/mysql/5/root.key @@ -0,0 +1 @@ +6vTWXiZUU5nz7AVCYaCis8GqVF6TZhHH diff --git a/examples/mysql/8/compose.yaml b/examples/mysql/8/compose.yaml new file mode 100644 index 0000000..b4578d6 --- /dev/null +++ b/examples/mysql/8/compose.yaml @@ -0,0 +1,46 @@ +version: "3.9" + +services: + mysql: + image: mysql:8.0.34 + container_name: mysql + hostname: mysql + restart: always + networks: + - db_network + ports: + - "3306:3306" + volumes: + - /etc/localtime:/etc/localtime:ro + - mysql_db:/var/lib/mysql + configs: + - source: mysql_conf + target: /etc/mysql/conf.d/my.cnf + mode: 0444 + secrets: + - mysql_root_key + environment: + - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_key + +volumes: + mysql_db: + +configs: + mysql_conf: + file: my.cnf + +secrets: + mysql_root_key: + file: root.key + +networks: + db_network: + name: db_network + external: true +# driver: bridge +# driver_opts: +# encrypted: 'true' +# ipam: +# driver: default +# config: +# - subnet: 172.21.0.1/24 diff --git a/examples/mysql/8/my.cnf b/examples/mysql/8/my.cnf new file mode 100644 index 0000000..ac541ff --- /dev/null +++ b/examples/mysql/8/my.cnf @@ -0,0 +1,4 @@ +[mysqld] +max_connections = 1000 +character-set-server = utf8mb4 +collation-server = utf8mb4_unicode_ci diff --git a/examples/mysql/8/root.key b/examples/mysql/8/root.key new file mode 100644 index 0000000..bffe010 --- /dev/null +++ b/examples/mysql/8/root.key @@ -0,0 +1 @@ +msQijJXzLmeEfmy3j5nQBn7hsVFbd6F3 diff --git a/examples/phpmyadmin/compose.yaml b/examples/phpmyadmin/compose.yaml new file mode 100644 index 0000000..a5c5e82 --- /dev/null +++ b/examples/phpmyadmin/compose.yaml @@ -0,0 +1,28 @@ +version: "3.9" + +services: + phpmyadmin: + image: phpmyadmin:5.2.1 + container_name: phpmyadmin + hostname: phpmyadmin + restart: always + networks: + - db_network + ports: + - "80:80" + volumes: + - /etc/localtime:/etc/localtime:ro + environment: + - PMA_ARBITRARY=1 + +networks: + db_network: + name: db_network + external: true +# driver: bridge +# driver_opts: +# encrypted: 'true' +# ipam: +# driver: default +# config: +# - subnet: 172.21.0.1/24 diff --git a/examples/portainer/compose.yaml b/examples/portainer/compose.yaml new file mode 100644 index 0000000..7e48711 --- /dev/null +++ b/examples/portainer/compose.yaml @@ -0,0 +1,30 @@ +version: "3.9" + +services: + portainer: + image: portainer/portainer-ce:2.19.0-alpine + container_name: portainer + hostname: portainer + restart: always + ports: + - "9000:9000" + - "9443:9443" + volumes: + - /etc/localtime:/etc/localtime:ro + - /var/run/docker.sock:/var/run/docker.sock + - portainer_data:/data + +volumes: + portainer_data: + +networks: + app_network: + name: app_network + external: true +# driver: bridge +# driver_opts: +# encrypted: 'true' +# ipam: +# driver: default +# config: +# - subnet: 172.21.0.1/24