Skip to content

Commit

Permalink
MS SQL Server - Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
XuanThuLab committed Aug 10, 2020
1 parent a4a4257 commit 6780207
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 0 deletions.
Binary file removed .DS_Store
Binary file not shown.
12 changes: 12 additions & 0 deletions MSSQL/bk/restore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# #CHECK MEDIA
# /opt/mssql-tools/bin/sqlcmd \
# -S localhost -U SA -P 'Password123' \
# -Q "RESTORE FILELISTONLY FROM DISK = '/var/opt/mssql/backup/xtlab.bak'"


/opt/mssql-tools/bin/sqlcmd \
-S localhost -U SA -P 'Password123' \
-Q 'RESTORE DATABASE xtlab FROM DISK = "/var/opt/mssql/backup/xtlab.bak" WITH MOVE "xtlab" TO "/var/opt/mssql/data/xtlab.mdf", MOVE "xtlab_log" TO "/var/opt/mssql/data/xtlab_log.ldf"'

Binary file added MSSQL/bk/xtlab.bak
Binary file not shown.
Binary file added MSSQL/bk/xtlab.en.bak
Binary file not shown.
24 changes: 24 additions & 0 deletions MSSQL/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3.7"

services:
xtlab-mssql:
image: "mcr.microsoft.com/mssql/server:2017-latest"
container_name: sqlserver-xtlab
restart: always
hostname: mssql
environment:
SA_PASSWORD: Password123 #Thiết lập password
ACCEPT_EULA: 'Y'
# Express:

volumes:
- mssqlvolume:/var/opt/mssql/data # thư mục lưu DB
- ./bk:/var/opt/mssql/backup
ports:
- "1433:1433"

volumes:
mssqlvolume:
name: sqlserver-xtlab-vl


20 changes: 20 additions & 0 deletions MSSQL/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Cài đặt MS SQL Server trên Docker
```
docker-compose up -d
```
container name: sqlserver-xtlab

port: 1433

user: sa

password: Password123

## Phục hồi dữ liệu mẫu
```
docker exec sqlserver-xtlab /var/opt/mssql/backup/restore.sh
```
Tên CSDL: xtlab

Cấu trúc dữ liệu mẫu:
https://xuanthulab.net/chay-sql-online-cong-cu-hoc-cau-lenh-sql.html

0 comments on commit 6780207

Please sign in to comment.