开始使用 Docker (Linux 上运行 SQL Server) 上的 SQL Server 容器 - SQL Server | Microsoft Docs教程
原文:开始使用 Docker (Linux 上运行 SQL Server) 上的 SQL Server 容器 - SQL Server | Microsoft Docs
选定的版本 SQL Server 2017 产品 - All SQL 版本
- Hide nothing
- Analytics Platform System (PDW) 版本
- 2016-AU7
- 2016-AU6
- SQL Data Warehouse 版本
- latest
- SQL Database managed instance 版本
- current
- SQL Database single database / elastic pool 版本
- current
- SQL Server 版本
- 2019 preview
- 2017
- 2016
- 2014
- SQL Server on Linux 版本
- 2019 preview
- 2017
快速入门:使用 Docker 运行 SQL Server 容器映像Quickstart: Run SQL Server container images with Docker
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
Choose your command shellBash PowerShell
本文内容
1. 先决条件
2. 请求和运行容器映像
3. 更改 SA 密码
4. 连接到 SQL Server
5. 创建和查询数据
6. 从容器外连接
7. 删除容器
8. Docker 演示
9. 后续步骤
适用于: SQL Server (仅限 Linux)Azure SQL 数据库Azure SQL 数据仓库并行数据仓库 APPLIES TO: SQL Server (Linux only) Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse
在本快速入门教程中,你使用 Docker 请求和运行 SQL Server 2017 容器映像 mssql server linux。In this quickstart, you use Docker to pull and run the SQL Server 2017 container image, mssql-server-linux. 然后使用 sqlcmd 进行连接,以便创建第一个数据库并运行查询。Then connect with sqlcmd to create your first database and run queries.
提示
如果你想要试用 SQL Server 2019 预览图像,请参阅这篇文章的 SQL Server 2019 预览版本。If you want to try the SQL Server 2019 preview image, see the SQL Server 2019 preview version of this article.
在本快速入门中使用 Docker 请求和运行 SQL Server 2019 预览版容器映像, mssql server。In this quickstart, you use Docker to pull and run the SQL Server 2019 preview container image, mssql-server. 然后使用 sqlcmd 进行连接,以便创建第一个数据库并运行查询。Then connect with sqlcmd to create your first database and run queries.
此映像包含在 Linux(基于 Ubuntu 16.04)上运行的 SQL Server。This image consists of SQL Server running on Linux based on Ubuntu 16.04. 它可与适用于 Linux 的 Docker 引擎 1.8 以上版本或适用于 Mac/Windows 的 Docker 配合使用。It can be used with the Docker Engine 1.8+ on Linux or on Docker for Mac/Windows. 本快速入门专门重点介绍使用 SQL Server 上linux映像。This quick start specifically focuses on using the SQL Server on linux image. 虽然未介绍 Windows 映像,但可在 mssql-server-windows-developer Docker 中心页上找到关于它的详细信息。The Windows image is not covered, but you can learn more about it on the mssql-server-windows-developer Docker Hub page.
先决条件Prerequisites[](#requirements)
-----------------------------------
- 适用于支持的任一 Linux 分发版的 Docker 引擎 1.8 以上版本,或适用于 Mac/Windows 的 Docker。Docker Engine 1.8+ on any supported Linux distribution or Docker for Mac/Windows. 有关详细信息,请参阅 Install Docker(安装 Docker)。For more information, see Install Docker.
- Docker overlay2存储驱动程序。Docker overlay2 storage driver. 这是大多数用户的默认值。This is the default for most users. 如果发现未使用此存储提供程序,需要进行更改,请参阅说明和中的警告docker 文档配置 overlay2。If you find that you are not using this storage provider and need to change, please see the instructions and warnings in the docker documentation for configuring overlay2.
- 2 gb 的磁盘空间最小值。Minimum of 2 GB of disk space.
- 2 GB 的 RAM 的最小值。Minimum of 2 GB of RAM.
- Linux 上的 SQL Server 的系统要求。System requirements for SQL Server on Linux.
请求和运行容器映像Pull and run the container image[](#pullandrun2017)
-------------------------------------------------------------
1. 从 Microsoft 容器注册表拉取 SQL Server 2017 Linux 容器映像。Pull the SQL Server 2017 Linux container image from Microsoft Container Registry.
bash 复制
sudo docker pull mcr.microsoft.com/mssql/server:2017-latest
PowerShell 复制
docker pull mcr.microsoft.com/mssql/server:2017-latest
提示
如果你想要试用 SQL Server 2019 预览图像,请参阅这篇文章的 SQL Server 2019 预览版本。If you want to try the SQL Server 2019 preview image, see the SQL Server 2019 preview version of this article.
前一个命令请求最新的 SQL Server 2017 容器映像。The previous command pulls the latest SQL Server 2017 container image. 如果想请求某个特定映像,需添加一个冒号和标记名称(例如 mcr.microsoft.com/mssql/server:2017-GA-ubuntu
。If you want to pull a specific image, you add a colon and the tag name (for example, mcr.microsoft.com/mssql/server:2017-GA-ubuntu
). 若要查看所有可用映像,请参阅mssql server Docker 中心页。To see all available images, see the mssql-server Docker hub page.
在本文中,bash 命令sudo
使用。For the bash commands in this article, sudo
is used. 在 MacOS 上,sudo
可能不需要。On MacOS, sudo
might not be required. 在 Linux 上,如果不想要使用sudo
若要运行 Docker,可以配置docker组,并将用户添加到该组。On Linux, if you do not want to use sudo
to run Docker, you can configure a docker group and add users to that group. 有关详细信息,请参阅安装后步骤适用于 Linux。For more information, see Post-installation steps for Linux.
2. 要使用 Docker 运行容器映像,可以从 Bash Shell (Linux/macOS) 或提升的 PowerShell 命令提示符使用以下命令。To run the container image with Docker, you can use the following command from a bash shell (Linux/macOS) or elevated PowerShell command prompt.
bash 复制
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' \
-p 1433:1433 --name sql1 \
-d mcr.microsoft.com/mssql/server:2017-latest
PowerShell 复制
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong!Passw0rd>" `
-p 1433:1433 --name sql1 `
-d mcr.microsoft.com/mssql/server:2017-latest
备注
密码应符合 SQL Server 默认密码策略,否则容器无法设置 SQL Server,将停止工作。The password should follow the SQL Server default password policy, otherwise the container can not setup SQL server and will stop working. 默认情况下,密码必须至少为 8 个字符长,且包含三个以下四种字符集的字符:大写字母、 小写字母、 十进制数字和符号。By default, the password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols. 你可以通过执行 docker logs 命令检查错误日志。You can examine the error log by executing the docker logs command.
备注
默认情况下,这会创建一个使用 SQL Server 2017 开发人员版的容器。By default, this creates a container with the Developer edition of SQL Server 2017. 在容器中运行生产版本的过程略有不同。The process for running production editions in containers is slightly different. 有关详细信息,请参阅运行生产容器映像。For more information, see Run production container images.
下表对前一个 docker run
示例中的参数进行了说明:The following table provides a description of the parameters in the previous docker run
example:
参数ParameterDescriptionDescription-e 'ACCEPT\_EULA=Y'-e 'ACCEPT\_EULA=Y'将 ACCEPT\_EULA 变量设置为任意值,以确认接受最终用户许可协议。Set the ACCEPT\_EULA variable to any value to confirm your acceptance of the End-User Licensing Agreement. SQL Server 映像的必需设置。Required setting for the SQL Server image.-e 'SA\_PASSWORD=<YourStrong!Passw0rd>'-e 'SA\_PASSWORD=<YourStrong!Passw0rd>'指定至少包含 8 个字符且符合 SQL Server 密码要求的强密码。Specify your own strong password that is at least 8 characters and meets the SQL Server password requirements. SQL Server 映像的必需设置。Required setting for the SQL Server image.-p 1433:1433-p 1433:1433建立主机环境(第一个值)上的 TCP 端口与容器(第二个值)中 TCP 端口的映射。Map a TCP port on the host environment (first value) with a TCP port in the container (second value). 在此示例中,SQL Server 侦听容器中的 TCP 1433 并公开的端口 1433,在主机上。In this example, SQL Server is listening on TCP 1433 in the container and this is exposed to the port, 1433, on the host.--name sql1--name sql1为容器指定一个自定义名称,而不是使用随机生成的名称。Specify a custom name for the container rather than a randomly generated one. 如果运行多个容器,则无法重复使用相同的名称。If you run more than one container, you cannot reuse this same name.mcr.microsoft.com/mssql/server:2017-latestmcr.microsoft.com/mssql/server:2017-latestSQL Server 2017 Linux 容器映像。The SQL Server 2017 Linux container image.
3. 要查看 Docker 容器,请使用 docker ps
命令。To view your Docker containers, use the docker ps
command.
bash 复制
sudo docker ps -a
PowerShell 复制
docker ps -a
将看到与如下屏幕截图相似的输出:You should see output similar to the following screenshot:
4. 如果“状态”列显示“正常运行”,则 SQL Server 将在容器中运行,并侦听“端口”列中指定的端口。If the STATUS column shows a status of Up, then SQL Server is running in the container and listening on the port specified in the PORTS column. 如果 SQL Server 容器的“状态”列显示“已退出”,则参阅配置指南的疑难解答部分。If the STATUS column for your SQL Server container shows Exited, see the Troubleshooting section of the configuration guide.
-h
(主机名)参数也非常有用,但为了简单起见,本教程中不使用它。The -h
(host name) parameter is also useful, but it is not used in this tutorial for simplicity. 这会将容器的内部名称更改为一个自定义值。This changes the internal name of the container to a custom value. 也就是以下 Transact-SQL 查询中返回的名称:This is the name you'll see returned in the following Transact-SQL query:
SQL 复制
SELECT @@SERVERNAME,
SERVERPROPERTY('ComputerNamePhysicalNetBIOS'),
SERVERPROPERTY('MachineName'),
SERVERPROPERTY('ServerName')
将 -h
和 --name
设为相同的值是一种很好的方法,可以轻松地识别目标容器。Setting -h
and --name
to the same value is a good way to easily identify the target container.
请求和运行容器映像Pull and run the container image[](#%E8%AF%B7%E6%B1%82%E5%92%8C%E8%BF%90%E8%A1%8C%E5%AE%B9%E5%99%A8%E6%98%A0%E5%83%8Fpull-and-run-the-container-image)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
1. 从 Docker 中心请求 SQL Server 2019 预览 Linux 容器映像。Pull the SQL Server 2019 preview Linux container image from Docker Hub.
bash 复制
sudo docker pull mcr.microsoft.com/mssql/server:2019-CTP2.3-ubuntu
PowerShell 复制
docker pull mcr.microsoft.com/mssql/server:2019-CTP2.3-ubuntu
提示
本快速入门使用 SQL Server 2019 预览 Docker 映像。This quickstart uses the SQL Server 2019 preview Docker image. 如果你想要运行 SQL Server 2017 映像,请参阅这篇文章的 SQL Server 2017 版本。If you want to run the SQL Server 2017 image, see the SQL Server 2017 version of this article.
前一个命令请求基于 Ubuntu 的最新 SQL Server 2019 预览容器图像。The previous command pulls the latest SQL Server 2019 preview container image based on Ubuntu. 若要改为使用基于 RedHat 的容器映像,请参阅基于运行 RHEL 的容器映像。To instead use container images based on RedHat, see Run RHEL-based container images. 如果想请求某个特定映像,需添加一个冒号和标记名称(例如 mcr.microsoft.com/mssql/server:2017-GA
。If you want to pull a specific image, you add a colon and the tag name (for example, mcr.microsoft.com/mssql/server:2017-GA
). 要查看所有可用映像,请参阅 mssql-server-linux Docker 中心页。To see all available images, see the mssql-server-linux Docker hub page.
在本文中,bash 命令sudo
使用。For the bash commands in this article, sudo
is used. 在 MacOS 上,sudo
可能不需要。On MacOS, sudo
might not be required. 在 Linux 上,如果不想要使用sudo
若要运行 Docker,可以配置docker组,并将用户添加到该组。On Linux, if you do not want to use sudo
to run Docker, you can configure a docker group and add users to that group. 有关详细信息,请参阅安装后步骤适用于 Linux。For more information, see Post-installation steps for Linux.
2. 要使用 Docker 运行容器映像,可以从 Bash Shell (Linux/macOS) 或提升的 PowerShell 命令提示符使用以下命令。To run the container image with Docker, you can use the following command from a bash shell (Linux/macOS) or elevated PowerShell command prompt.
bash 复制
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' \
-p 1433:1433 --name sql1 \
-d mcr.microsoft.com/mssql/server:2019-CTP2.3-ubuntu
PowerShell 复制
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong!Passw0rd>" `
-p 1433:1433 --name sql1 `
-d mcr.microsoft.com/mssql/server:2019-CTP2.3-ubuntu
备注
密码应符合 SQL Server 默认密码策略,否则容器无法设置 SQL Server,将停止工作。The password should follow the SQL Server default password policy, otherwise the container can not setup SQL server and will stop working. 默认情况下,密码必须至少为 8 个字符长,且包含三个以下四种字符集的字符:大写字母、 小写字母、 十进制数字和符号。By default, the password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols. 你可以通过执行 docker logs 命令检查错误日志。You can examine the error log by executing the docker logs command.
备注
默认情况下,这与开发人员版的 SQL Server 2019 预览版创建一个容器。By default, this creates a container with the Developer edition of SQL Server 2019 preview.
下表对前一个 docker run
示例中的参数进行了说明:The following table provides a description of the parameters in the previous docker run
example:
参数ParameterDescriptionDescription-e 'ACCEPT\_EULA=Y'-e 'ACCEPT\_EULA=Y'将 ACCEPT\_EULA 变量设置为任意值,以确认接受最终用户许可协议。Set the ACCEPT\_EULA variable to any value to confirm your acceptance of the End-User Licensing Agreement. SQL Server 映像的必需设置。Required setting for the SQL Server image.-e 'SA\_PASSWORD=<YourStrong!Passw0rd>'-e 'SA\_PASSWORD=<YourStrong!Passw0rd>'指定至少包含 8 个字符且符合 SQL Server 密码要求的强密码。Specify your own strong password that is at least 8 characters and meets the SQL Server password requirements. SQL Server 映像的必需设置。Required setting for the SQL Server image.-p 1433:1433-p 1433:1433建立主机环境(第一个值)上的 TCP 端口与容器(第二个值)中 TCP 端口的映射。Map a TCP port on the host environment (first value) with a TCP port in the container (second value). 在此示例中,SQL Server 侦听容器中的 TCP 1433 并公开的端口 1433,在主机上。In this example, SQL Server is listening on TCP 1433 in the container and this is exposed to the port, 1433, on the host.--name sql1--name sql1为容器指定一个自定义名称,而不是使用随机生成的名称。Specify a custom name for the container rather than a randomly generated one. 如果运行多个容器,则无法重复使用相同的名称。If you run more than one container, you cannot reuse this same name.mcr.microsoft.com/mssql/server:2019-CTP2.3-ubuntumcr.microsoft.com/mssql/server:2019-CTP2.3-ubuntuSQL Server 2019 CTP 2.3 Linux 容器映像。The SQL Server 2019 CTP 2.3 Linux container image.
3. 要查看 Docker 容器,请使用 docker ps
命令。To view your Docker containers, use the docker ps
command.
bash 复制
sudo docker ps -a
PowerShell 复制
docker ps -a
将看到与如下屏幕截图相似的输出:You should see output similar to the following screenshot:
4. 如果“状态”列显示“正常运行”,则 SQL Server 将在容器中运行,并侦听“端口”列中指定的端口。If the STATUS column shows a status of Up, then SQL Server is running in the container and listening on the port specified in the PORTS column. 如果 SQL Server 容器的“状态”列显示“已退出”,则参阅配置指南的疑难解答部分。If the STATUS column for your SQL Server container shows Exited, see the Troubleshooting section of the configuration guide.
-h
(主机名)参数也非常有用,但为了简单起见,本教程中不使用它。The -h
(host name) parameter is also useful, but it is not used in this tutorial for simplicity. 这会将容器的内部名称更改为一个自定义值。This changes the internal name of the container to a custom value. 也就是以下 Transact-SQL 查询中返回的名称:This is the name you'll see returned in the following Transact-SQL query:
SQL 复制
SELECT @@SERVERNAME,
SERVERPROPERTY('ComputerNamePhysicalNetBIOS'),
SERVERPROPERTY('MachineName'),
SERVERPROPERTY('ServerName')
将 -h
和 --name
设为相同的值是一种很好的方法,可以轻松地识别目标容器。Setting -h
and --name
to the same value is a good way to easily identify the target container.
更改 SA 密码Change the SA password[](#sapassword)
----------------------------------------------
SA 帐户是安装过程中在 SQL Server 实例上创建的系统管理员。The SA account is a system administrator on the SQL Server instance that gets created during setup. 创建 SQL Server 容器后,通过在容器中运行 echo $MSSQL_SA_PASSWORD
,可发现指定的 MSSQL_SA_PASSWORD
环境变量。After creating your SQL Server container, the MSSQL_SA_PASSWORD
environment variable you specified is discoverable by running echo $MSSQL_SA_PASSWORD
in the container. 出于安全考虑,请考虑更改 SA 密码。For security purposes, change your SA password.
1. 选择 SA 用户要使用的强密码。Choose a strong password to use for the SA user.
2. 使用 docker exec
运行sqlcmd,以使用 Transact-SQL 更改密码。Use docker exec
to run sqlcmd to change the password using Transact-SQL. 将 <YourStrong!Passw0rd>
和 <YourNewStrong!Passw0rd>
替换为自己的密码值。Replace <YourStrong!Passw0rd>
and <YourNewStrong!Passw0rd>
with your own password values.
bash 复制
sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd \
-S localhost -U SA -P '<YourStrong!Passw0rd>' \
-Q 'ALTER LOGIN SA WITH PASSWORD="<YourNewStrong!Passw0rd>"'
PowerShell 复制
docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd `
-S localhost -U SA -P "<YourStrong!Passw0rd>" `
-Q "ALTER LOGIN SA WITH PASSWORD='<YourNewStrong!Passw0rd>'"
连接到 SQL ServerConnect to SQL Server[](#connect-to-sql-server)
-------------------------------------------------------------
下列步骤在容器内部使用 SQL Server 命令行工具 sqlcmd 来连接 SQL Server。The following steps use the SQL Server command-line tool, sqlcmd, inside the container to connect to SQL Server.
1. 使用 docker exec -it
命令在运行的容器内部启动交互式 Bash Shell。Use the docker exec -it
command to start an interactive bash shell inside your running container. 在下面的示例中,sql1
是在创建容器时由 --name
参数指定的名称。In the following example sql1
is name specified by the --name
parameter when you created the container.
bash 复制
sudo docker exec -it sql1 "bash"
PowerShell 复制
docker exec -it sql1 "bash"
2. 一旦位于容器内部,使用 sqlcmd 进行本地连接。Once inside the container, connect locally with sqlcmd. 默认情况下,sqlcmd 不在路径之中,因此需要指定完整路径。Sqlcmd is not in the path by default, so you have to specify the full path.
bash 复制
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourNewStrong!Passw0rd>'
提示
可以省略命令行上提示要输入的密码。You can omit the password on the command-line to be prompted to enter it.
3. 如果成功,应会显示 sqlcmd 命令提示符:1>
。If successful, you should get to a sqlcmd command prompt: 1>
.
创建和查询数据Create and query data[](#create-and-query-data)
------------------------------------------------------
以下部分将引导你使用 sqlcmd 和 Transact-SQL 完成新建数据库、添加数据并运行简单查询的整个过程。The following sections walk you through using sqlcmd and Transact-SQL to create a new database, add data, and run a simple query.
新建数据库Create a new database[](#create-a-new-database)
以下步骤创建一个名为 TestDB
的新数据库。The following steps create a new database named TestDB
.
1. 在 sqlcmd 命令提示符中,粘贴以下 Transact-SQL 命令以创建测试数据库:From the sqlcmd command prompt, paste the following Transact-SQL command to create a test database:
SQL 复制
CREATE DATABASE TestDB
2. 在下一行中,编写一个查询以返回服务器上所有数据库的名称:On the next line, write a query to return the name of all of the databases on your server:
SQL 复制
SELECT Name from sys.Databases
3. 前两个命令没有立即执行。The previous two commands were not executed immediately. 必须在新行中键入 GO
才能执行以前的命令:You must type GO
on a new line to execute the previous commands:
SQL 复制
GO
插入数据Insert data[](#insert-data)
接下来创建一个新表 Inventory
,然后插入两个新行。Next create a new table, Inventory
, and insert two new rows.
1. 在 sqlcmd 命令提示符中,将上下文切换到新的 TestDB
数据库:From the sqlcmd command prompt, switch context to the new TestDB
database:
SQL 复制
USE TestDB
2. 创建名为 Inventory
的新表:Create new table named Inventory
:
SQL 复制
CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT)
3. 将数据插入新表:Insert data into the new table:
SQL 复制
INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154);
4. 要执行上述命令的类型 GO
:Type GO
to execute the previous commands:
SQL 复制
GO
选择数据Select data[](#select-data)
现在,运行查询以从 Inventory
表返回数据。Now, run a query to return data from the Inventory
table.
1. 通过 sqlcmd 命令提示符输入查询,以返回 Inventory
表中数量大于 152 的行:From the sqlcmd command prompt, enter a query that returns rows from the Inventory
table where the quantity is greater than 152:
SQL 复制
SELECT * FROM Inventory WHERE quantity > 152;
2. 执行命令:Execute the command:
SQL 复制
GO
退出 sqlcmd 命令提示符Exit the sqlcmd command prompt[](#exit-the-sqlcmd-command-prompt)
1. 要结束 sqlcmd 会话,请键入 QUIT
:To end your sqlcmd session, type QUIT
:
SQL 复制
QUIT
2. 要在容器中退出交互式命令提示,请键入 exit
。To exit the interactive command-prompt in your container, type exit
. 退出交互式 Bash Shell 后,容器将继续运行。Your container continues to run after you exit the interactive bash shell.
从容器外连接Connect from outside the container[](#connectexternal)
-------------------------------------------------------------
还可以从支持 SQL 连接的任何 Linux、Windows 或 macOS 外部工具连接到 Docker 计算机上的 SQL Server 实例。You can also connect to the SQL Server instance on your Docker machine from any external Linux, Windows, or macOS tool that supports SQL connections.
以下步骤在容器外使用 sqlcmd 连接在容器中运行的 SQL Server。The following steps use sqlcmd outside of your container to connect to SQL Server running in the container. 这些步骤假定你已在容器外安装了 SQL Server 命令行工具。These steps assume that you already have the SQL Server command-line tools installed outside of your container. 该原理同样适用时使用其他工具,但连接的过程是唯一的每个工具。The same principles apply when using other tools, but the process of connecting is unique to each tool.
1. 查找承载容器的计算机的 IP 地址。Find the IP address for the machine that hosts your container. 在 Linux 上,使用 ifconfig 或 ip addr。在 Windows 上,使用 ipconfig。On Linux, use ifconfig or ip addr. On Windows, use ipconfig.
2. 运行 sqlcmd,指定 IP 地址和映射容器中的端口 1433 的端口。Run sqlcmd specifying the IP address and the port mapped to port 1433 in your container. 在此示例中,这是同一个端口,1433,在主机上。In this example, that is the same port, 1433, on the host machine. 如果主机计算机上指定其他映射的端口,你将在此处使用它。If you specified a different mapped port on the host machine, you would use it here.
bash 复制
sqlcmd -S 10.3.2.4,1433 -U SA -P '<YourNewStrong!Passw0rd>'
PowerShell 复制
sqlcmd -S 10.3.2.4,1433 -U SA -P "<YourNewStrong!Passw0rd>"
3. 运行 Transact-SQL 命令。Run Transact-SQL commands. 完成后,键入 QUIT
。When finished, type QUIT
.
连接到 SQL Server 的其他常见工具包括:Other common tools to connect to SQL Server include:
- Visual Studio CodeVisual Studio Code
- 适用于 Windows 的 SQL Server Management Studio (SSMS)SQL Server Management Studio (SSMS) on Windows
- Azure Data StudioAzure Data Studio
- mssql-cli(预览版)mssql-cli (Preview)
删除容器Remove your container[](#remove-your-container)
---------------------------------------------------
如果想删除本教程中使用的 SQL Server 容器,请运行以下命令:If you want to remove the SQL Server container used in this tutorial, run the following commands:
bash 复制
sudo docker stop sql1
sudo docker rm sql1
PowerShell 复制
docker stop sql1
docker rm sql1
警告
停止并永久删除容器会删除容器中的所有 SQL Server 数据。Stopping and removing a container permanently deletes any SQL Server data in the container. 如果你需要保留数据,请在容器外创建并复制备份文件或使用容器数据暂留技术。If you need to preserve your data, create and copy a backup file out of the container or use a container data persistence technique.
Docker 演示Docker demo[](#docker-demo)
------------------------------------
尝试对 Docker 使用 SQL Server 容器映像后,你可能想知道如何 Docker 是如何用于改进开发和测试的。After you have tried using the SQL Server container image for Docker, you might want to know how Docker is used to improve development and testing. 下面的视频介绍如何在持续集成和部署方案中使用 Docker。The following video shows how Docker can be used in a continuous integration and deployment scenario.
后续步骤Next steps[](#next-steps)
-----------------------------
有关如何将数据库备份文件还原到容器中的教程,请参阅在 Linux Docker 容器中还原 SQL Server 数据库。For a tutorial on how to restore database backup files into a container, see Restore a SQL Server database in a Linux Docker container. 若要浏览其他方案,例如运行多个容器数据暂留和故障排除,请参阅Docker 上的配置 SQL Server 容器映像。To explore other scenarios, such as running multiple containers, data persistence, and troubleshooting, see Configure SQL Server container images on Docker.
并且,请查看 mssql-docker GitHub 存储库,了解资源、反馈和已知问题。Also, check out the mssql-docker GitHub repository for resources, feedback, and known issues.
反馈
--
我们衷心期待你的反馈意见。 请选择要提供的反馈类型:
产品反馈 Sign in to give content feedback 也可以直接在 GitHub %0A%20Content%20Source%3A%20%5Bdocs%2Flinux%2Fquickstart-install-connect-docker.md%5D(https%3A%2F%2Fgithub.com%2FMicrosoftDocs%2Fsql-docs.zh-cn%2Fblob%2Flive%2Fdocs%2Flinux%2Fquickstart-install-connect-docker.md)%0A%20Product%3A%20sql%0A%20GitHub%20Login%3A%20%40rothja%0A%20Microsoft%20Alias%3A%20jroth)上提供反馈。 内容反馈 也可以直接在 GitHub %0A%20Content%20Source%3A%20%5Bdocs%2Flinux%2Fquickstart-install-connect-docker.md%5D(https%3A%2F%2Fgithub.com%2FMicrosoftDocs%2Fsql-docs.zh-cn%2Fblob%2Flive%2Fdocs%2Flinux%2Fquickstart-install-connect-docker.md)%0A%20Product%3A%20sql%0A%20GitHub%20Login%3A%20%40rothja%0A%20Microsoft%20Alias%3A%20jroth)上提供反馈。
我们的反馈系统是在 GitHub Issues 的基础之上构建而成。 请访问我们的博客,了解详细信息。
Liquid error: Can't find the localized string giveDocumentationFeedback for template Conceptual.
问题标题 发表评论 提交反馈本文档当前无任何反馈。 提交的反馈将显示在此处。 - 0 条未结
- 0 条已关闭
没有未决问题
没有已关闭的问题
在 GitHub 上查看 中文 (中华人民共和国)- 旧版文档
- 博客
- 参与
- 隐私和 Cookie
- 使用条款
- 网站反馈
- 商标