Now .net core has a cross-platform, and we all have to spend linux spend a docker. .Net often with supporting the use of SQL SERVER previously been windows only, but from the beginning of 2017 already supports SQL Server running on a docker, also said that now SQL Serer ready to run in the linux.
In the following presentation on Ubuntu 16.4 installs and uses SQL Server 2019-CTP3.2
SQL Server in Docker
sudo docker pull mcr.microsoft.com/mssql/server:2019-CTP3.2-ubuntu
Use docker pull command from the docker hub sqlserver pulling of the mirror 2019-ctp3.2
sudo mkdir /hd2/sqlserver2019_data
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=dev@123," -p 14330:1433 --name sqlserver2019 -v /hd2/sqlserver2019_data:/var/opt/mssql -d mcr.microsoft.com/mssql/server:2019-CTP3.2-ubuntu
Use docker run command to start the container, wherein the use is to be noted that the -v parameter specifies the directory is mounted to the container sqlserver2019_data / var / opt / mssql directory, which is used to store the database file, so it is best mounted to the outer outside of the container, the container to avoid because they do not accidentally delete data loss
sudo docker ps -a
Use docker ps command to view the operation of the vessel can be seen running sqlserver2019
Connect to SQL Server using the command line
sudo docker exec -it sqlserver2019 "bash"
Log on to the inside of the container execute commands using the docker exec command
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "dev@123,"
Execute commands inside the container, open the sqlcmd
After opening sqlcmd we can operate some of the database, such as creating a database, creating tables, query data.
CREATE DATABASE TEST_DB
GO
USE TEST_DB
GO
CREATE TABLE Table1 (ID INT, NAME NVARCHAR(50))
GO
Insert Into Table1 Values (0, 'agile')
Creating TEST_DB database; create table Table1; insert a row; lookup table data
we use SQL Server docker run can also use Sql Server Management Studio to manage.
Use server ip plus port Once connected, you can see just the new database table TABLE1 TEST_DB with which there are data. Management can use SSMS after much simpler with the use of other versions of SQL Server lacks distinction.
At this point SQL Server in the basic operations of presentation Docker almost, and many more advanced features such as failover clustering configuration, replication subscription, Always On environment configuration and other functions with the windows a little difference we can try it yourself.