Docker install Sql Server deployment

Foreword

  In today's container concept more and more popular, .Net Core project can also be cross-platform deployment, then think under Sql Server can not it? Of course it is possible. This article is to introduce today Docker deployment configuration and connection Sql Server . Based on Centos7 .

Configuring Docker link Sql Server

  Prerequisite (at least 2 GB of disk space of at least 2 GB of the RAM ). We now begin the installation configuration:

  Docker Hub query and find the introduction of the Microsoft SQL Server.

       

 

  Then on the basis of this docker pull mirroring

 docker pull mcr.microsoft.com/mssql/server:2017-latest

  View mirror and allow this image

docker images
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=MyPassWord123"  -p 1433:1433 --name sql1  -d mcr.microsoft.com/mssql/server:2017-latest

 

  And then see whether to allow successful

Docker ps -a

 

  This will not only allow appear next chart success, display UP ( if that fails, by docker logs a container name to view the error log )

 

 

  Then here we configure the SQL Server, then we enter the actual container operations.

sudo docker exec -it sql1 "bash"

/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "MyPassWord123"

  Then you can now perform routine database operations, and execute the input command Go End

 

 

    Create a library

CREATE DATABASE TestDB

 

    Use the library, create a table

USE TestDB

CREATE TABLE Inventory (id INT, LastName NVARCHAR(50), FirstName NVARCHAR(50))

 

    Lookup table

Select * from  Inventory

 

    User-created table query

select name from sysobjects where type = 'U'

 

 

  System table sysobjects saved are database objects , wherein the type indicates the type of the various objects, comprises :

  U = user table

  S = system table

  C = CHECK constraints

  D = Default or DEFAULT constraint

  F = FOREIGN KEY constraint

  L = log

  FN = scalar function

  IF = internally fitted table function

  P = Stored Procedures

  PK = PRIMARY KEY constraints (type K )

  RF = Replication filter stored procedure

  TF = Table function

  TR = Trigger

  UQ = UNIQUE constraint (type K )

  V = view

  X = Extended stored procedure and associated object information.

 

  

Other configurations

  First, change the sa login password

sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd  -S localhost -U SA -P "MyPassWord123"  -Q 'ALTER LOGIN SA WITH PASSWORD="MyPassWord456"'

 

  Second, the data retention

    • Loading of host data volume directory
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=MyPassWord456' -p 1433:1433 -v  /var/opt/mssql -d mcr.microsoft.com/mssql/server:2017-latest

 

    •  Using the data volume container
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=MyPassWord456' -p 1433:1433 -v sqlvolume:/var/opt/mssql -d mcr.microsoft.com/mssql/server:2017-latest

 

  Third, remove or unload the container

     Delete container: Docker RM container name

    Remove the mirror: Docker rmi mirror name

    Exit container ; Ctrl + D

 


 

    Fu Chi when the deposit lofty, Muxian Xian, absolutely lust, abandoned suspect delay, so that the end for Chi, the mortgage then be kept, Ceran have a sense; forbearance flexion and extension, to the fine, wide consultation to ask, in addition to too stingy, although remain flooded, what harm Fun in the United States, hang in bad.

    If recounts Qiangyi, meaning not generous, only mediocre stagnation in the vulgar, silently beam in love, forever channeling volt mediocre, dirty can not help but to carry on.

 Welcome to scan the next Fanger Wei code, and the more I learn C # knowledge together

 

 

 

  

Guess you like

Origin www.cnblogs.com/hulizhong/p/11271739.html