## 1.创建数据持久化文件夹 sudo mkdir -p /opt/mssql/data/ #开启目录权限 sudo chmod a+rwx /opt/mssql/data/ #开启docker挂载权限 sudo chmod a+rw /var/run/docker.sock ## 2.拉取最新 ms sql 2019 镜像 sudo docker pull mcr.microsoft.com/mssql/server:2019-latest ## 3.运行容器 sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=P@ssw0rd" \ -p 1433:1433 --name mssql -h mssql \ -v /opt/mssql/data/:/var/opt/mssql/data/ \ -d mcr.microsoft.com/mssql/server:2019-latest ## 默认密码 # 账户:SA # 密码:P@ssw0rd ## 修改密码 sudo docker exec -it mssql /opt/mssql-tools/bin/sqlcmd \ -S localhost -U SA -P "P@ssw0rd" \ -Q 'ALTER LOGIN SA WITH PASSWORD="123456@P@ssw0rd>"'