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

Blog    

Recommend

Solve the problem of insufficient docker disk space

After the server where Docker is located has been...

Detailed process of compiling and installing Storm on Kylin V10 server

1 Introduction Apache Storm is a free, open sourc...

In-depth explanation of InnoDB locks in MySQL technology

Table of contents Preface 1. What is a lock? 2. L...

How to change password in MySQL 5.7.18

How to change the password in MySQL 5.7.18: 1. Fi...

Native JavaScript to achieve skinning

The specific code for implementing skinning with ...

Detailed process of zabbix monitoring process and port through agent

Environment Introduction Operating system: centos...

Detailed explanation of Linux file operation knowledge points

Related system calls for file operations create i...

JavaScript implements draggable progress bar

This article shares the specific code of JavaScri...

Vue project packaging and optimization implementation steps

Table of contents Packaging, launching and optimi...

Steps to repair grub.cfg file corruption in Linux system

Table of contents 1. Introduction to grub.cfg fil...

uni-app WeChat applet authorization login implementation steps

Table of contents 1. Application and configuratio...

Detailed explanation of MySQL transaction isolation level and MVCC

Table of contents Transaction Isolation Level Pro...