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

Summary of a CSS code that makes the entire site gray

In order to express the deep condolences of peopl...

Detailed explanation of Object.create instance usage in js

1. Create a new object using the Object.create() ...

Detailed explanation of the Docker deployment tutorial for Jenkins beginners

This article deploys Jenkins+Maven+SVN+Tomcat thr...

Json advantages and disadvantages and usage introduction

Table of contents 1. What is JSON 1.1 Array liter...

VMware vCenter 6.7 installation process (graphic tutorial)

background I originally wanted to download a 6.7 ...

Transplanting the mkfs.vfat command in busybox under Linux system

In order to extend the disk life for storing audi...

Java imports data from excel into mysql

Sometimes in our actual work, we need to import d...

Vue+ElementUI implements paging function-mysql data

Table of contents 1. Problem 2. Solution 2.1 Pagi...

Implementation of MySQL GRANT user authorization

Authorization is to grant certain permissions to ...

Linux CentOS6.5 yum install mysql5.6

This article shares the simple process of install...

CSS3 realizes particle animation effect when matching kings

When coding, you will find that many things have ...

Share MySql8.0.19 installation pit record

The previous article introduced the installation ...

A brief introduction to MySQL functions

Table of contents 1. Mathematical functions 2. St...