JiShe.IOT.Admin/DockerComposeShells/docker-compose-sqlserver.yml
2025-09-01 23:44:57 +08:00

92 lines
2.3 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.

version: '3.8'
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
container_name: sqlserver-2022
hostname: sqlserver-2022
restart: unless-stopped
privileged: true
ports:
- "${SQLSERVER_PORT}:1433"
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=${SQLSERVER_SA_PASSWORD}
- MSSQL_PID=${SQLSERVER_EDITION}
- TZ=Asia/Shanghai
volumes:
- sqlserver-data:/var/opt/mssql
- sqlserver-logs:/var/opt/mssql/log
- ./sqlserver/init:/docker-entrypoint-initdb.d
- ./sqlserver/backup:/var/opt/mssql/backup
deploy:
resources:
limits:
cpus: "4.0"
memory: 8g
reservations:
cpus: "2.0"
memory: 4g
networks:
- sqlserver-net
healthcheck:
test: ["CMD-SHELL", "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SQLSERVER_SA_PASSWORD} -Q 'SELECT 1' || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
stdin_open: true
tty: true
# SQL Server Management Studio (可选基于Web的管理界面)
sqlserver-web:
image: mcr.microsoft.com/mssql/server:2022-latest
container_name: sqlserver-web
hostname: sqlserver-web
restart: unless-stopped
ports:
- "${SQLSERVER_WEB_PORT}:8080"
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=${SQLSERVER_SA_PASSWORD}
- MSSQL_PID=${SQLSERVER_EDITION}
- TZ=Asia/Shanghai
volumes:
- ./sqlserver/web-config:/var/opt/mssql/web-config
depends_on:
sqlserver:
condition: service_healthy
networks:
- sqlserver-net
command: >
/bin/bash -c "
# 安装SQL Server Web管理工具
apt-get update && apt-get install -y curl wget &&
# 这里可以添加Web管理界面的安装脚本
echo 'SQL Server Web management interface ready' &&
tail -f /dev/null
"
networks:
sqlserver-net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.24.0.0/16
gateway: 172.24.0.1
volumes:
sqlserver-data:
driver: local
driver_opts:
type: none
o: bind
device: ./sqlserver/data
sqlserver-logs:
driver: local
driver_opts:
type: none
o: bind
device: ./sqlserver/logs