1. 拉取SqlServer2019镜像
sudo docker pull mcr.microsoft.com/mssql/server:2019-latest
2. 创建容器+挂载:
sudo docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Xu123456' -p 1433:1433 --name sqlserver2019 --net mynetwork --ip 172.18.0.3 -v /home/xujk/Work/Docker/Sqlserver/Sql2019/data:/var/opt/mssql -d mcr.microsoft.com/mssql/server:2019-latest
发现报错:
参考官网:
https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-docker?view=sql-server-2017#buildnonrootcontainer
修改命令为:
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Xu123456' --cap-add SYS_PTRACE -u 0:0 -p 1433:1433 --name sqlserver2019 --net mynetwork --ip 172.18.0.3 -v /home/xujk/Work/Docker/Sqlserver/Sql2019/data:/var/opt/mssql -d mcr.microsoft.com/mssql/server:2019-latest
执行成功
通过vs连接数据库测试,成功