Now .net core is cross-platform, and everyone is using Linux and Docker. SQL SERVER, which is often used with .net, has always been Windows only, but since SQL Server 2017, it has supported running on Docker, which means that SQL Serer can now run on Linux. SQL Server in Docker sudo docker pull mcr.microsoft.com/mssql/server:2019-CTP3.2-ubuntu Use the docker pull command to pull the image of sqlserver 2019-ctp3.2 from docker hub 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 the docker run command to start the container. Note that the -v parameter specifies that the sqlserver2019_data directory is mounted to the container's /var/opt/mssql directory. This directory is used to store database files, so it is best to mount it outside the container to avoid data loss due to accidental container deletion. sudo docker ps -a Use the docker ps command to view the running status of the container, and you can see that sqlserver2019 is running Connecting to SQL Server Using the Command Line sudo docker exec -it sqlserver2019 "bash" Use the docker exec command to log in to the container and execute commands /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P dev@123, Execute the command inside the container and open sqlcmd CREATE DATABASE TEST_DB GO USE TEST_DB GO CREATE TABLE Table1 (ID INT, NAME NVARCHAR(50)) GO Insert Into Table1 Values (0, 'agile') Create TEST_DB database; create table Table1; insert a row of data; query table data The SQL Server we run using Docker can also be managed using Sql Server Management Studio. After successfully connecting using the server IP and port, you can see that the newly created database TEST_DB and table TABLE1 as well as the data in them are all there. It is much easier to manage with SSMS, and there is no difference from using other versions of SQL Server. So far, the basic operations of SQL Server in Docker have been demonstrated. There are more advanced features such as configuring failover clusters, replication subscriptions, Always On, etc., which are a little different from the Windows environment configuration. You can try it yourself. This is the end of this article about using Docker to run SQL Server. For more information about running SQL Server with Docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! Author: Agile.Zhou(kklldog) You may also be interested in:
|
<<: About WeChat Mini Program to implement cloud payment
>>: What does mysql database do
Table of contents Step 1: Update Packages on Cent...
In order to express the deep condolences of peopl...
1. Create a new object using the Object.create() ...
This article deploys Jenkins+Maven+SVN+Tomcat thr...
Table of contents 1. What is JSON 1.1 Array liter...
Background description: On an existing load balan...
background I originally wanted to download a 6.7 ...
In order to extend the disk life for storing audi...
Sometimes in our actual work, we need to import d...
Table of contents 1. Problem 2. Solution 2.1 Pagi...
Authorization is to grant certain permissions to ...
This article shares the simple process of install...
When coding, you will find that many things have ...
The previous article introduced the installation ...
Table of contents 1. Mathematical functions 2. St...