Implementation of running SQL Server using Docker

Implementation of running SQL Server using Docker

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.
The following demonstrates the installation and use of SQL Server 2019-CTP3.2 on Ubuntu 16.4

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
After opening sqlcmd, we can perform some database operations, such as creating a database, creating a table, querying data, etc.

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)
Source: http://www.cnblogs.com/kklldog/

You may also be interested in:
  • Install SQL Server database on Linux system through Docker
  • Detailed steps for deploying Microsoft Sql Server with Docker
  • Docker deploys Mysql, .Net6, Sqlserver and other containers
  • Implementation of Docker deployment of SQL Server 2019 Always On cluster
  • How to run Microsoft SQL Server 2017 using Docker
  • Deploy MSSQL in a Docker container

<<:  About WeChat Mini Program to implement cloud payment

>>:  What does mysql database do

Recommend

How to add Vite support to old Vue projects

1. Introduction I have taken over a project of th...

15 important variables you must know about MySQL performance tuning (summary)

Preface: MYSQL should be the most popular WEB bac...

How to embed flash video format (flv, swf) files in html files

Flash file formats: .FLV and .SWF There are two ex...

How to use Volume to transfer files between host and Docker container

I have previously written an article about file t...

Analysis and solution of a.getAttribute(href,2) problem in IE6/7

Brief description <br />In IE6 and 7, in a ...

The difference between Vue interpolation expression and v-text directive

Table of contents 1. Use plugin expressions 2. Us...

Solution to the low writing efficiency of AIX mounted NFS

Services provided by NFS Mount: Enable the /usr/s...

Introduction to fork in multithreading under Linux

Table of contents Question: Case (1) fork before ...

Detailed explanation of the application of CSS Sprite

CSS Sprite, also known as CSS Sprite, is an image...

Detailed explanation of the use of MySQL DML statements

Preface: In the previous article, we mainly intro...

SQL statements in Mysql do not use indexes

MySQL query not using index aggregation As we all...

WeChat Mini Program User Authorization Best Practices Guide

Preface When developing WeChat applets, you often...

Problems and solutions of using TweenMax animation library in angular

I have nothing to do recently, so I tinker with C...