docker-compose/description/compose.yaml
2024-05-17 01:00:16 +00:00

106 lines
2.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 指定API版本号
version: "3.9"
# 指定文件名称
name: ${NAME}
# 服务相关
services:
## 服务1
${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
#### 挂载存储卷需在volumes部分设置卷相关参数
- ${VOLUME_NAME}:${CONTAINER_PATH}
#### 挂载主机目录
- ${HOST_PATH}:${CONTAINER_PATH}
### 使用的配置需在configs部分设置配置相关参数
configs:
- ${CONFIG_NAME}
### 使用的凭据需在secrets部分设置凭据相关参数
secrets:
- ${SECRET_NAME}
### 容器内环境变量
environment:
- ${KEY}=${VALUE}
### 运行容器时执行的命令
command: ${COMMAND}
### 当前服务依赖的容器
depends_on:
- ${SERVICE_NAME}
### 容器的网络模式
network_mode: host
### 容器的端口号
ports:
- ${HOST_PORT}:${CONTAINER_PORT}
### 容器的网络
networks:
- ${NETWORK_NAME}
# 存储卷相关
volumes:
## 存储卷1
${VOLUME_NAME}:
## 存储卷名称
name: ${VOLUME_NAME}
## 是否使用已存在的存储卷
external: true
# 配置相关
configs:
## 配置1
${CONFIG_NAME}:
### 配置名称
name: ${CONFIG_NAME}
### 是否使用已存在的配置
external: true
### 配置对应的文件
file: ${CONFIG_FILE_NAME}
# 凭据相关
secrets:
## 凭据1
${SECRET_NAME}:
### 凭据名称
name: ${SECRET_NAME}
### 是否使用已存在的凭据
external: true
### 凭据对应的文件
file: ${SECRddET_FILE_NAME}
# 网络相关
networks:
## 网络1
${NETWORK_NAME}:
## 网络名称
name: ${NETWORK_NAME}
## 是否使用已存在的网络
external: true
## 网络适配器
driver: bridge
## 网络适配器参数
driver_opts:
### 是否加密
encrypted: 'true'
## 网络参数
ipam:
### 适配器
driver: default
### 配置
config:
#### 网段
- subnet: 172.21.0.1/24