Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 8c7b888

Browse files
authored
Merge pull request #10203 from rothja/sqllinuxfresh1
Freshness update for docker quickstart
2 parents 42616dc + 7564802 commit 8c7b888

3 files changed

Lines changed: 110 additions & 26 deletions

File tree

docs/linux/quickstart-install-connect-docker.md

Lines changed: 104 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: Get started with SQL Server containers on Docker (running SQL Server on Linux)
2+
title: Get started with SQL Server Linux containers on Docker
33
titleSuffix: SQL Server
44
description: This quickstart shows how to use Docker to run the SQL Server 2017 and 2019 container images. You then create and query a database with sqlcmd.
55
author: rothja
66
ms.author: jroth
77
manager: craigg
8-
ms.date: 04/10/2019
8+
ms.date: 05/14/2019
99
ms.topic: conceptual
1010
ms.prod: sql
1111
ms.technology: linux
@@ -15,6 +15,7 @@ ms.assetid: 82737f18-f5d6-4dce-a255-688889fdde69
1515
moniker: ">= sql-server-linux-2017 || >= sql-server-2017 || =sqlallproducts-allversions"
1616
zone_pivot_groups: cs1-command-shell
1717
---
18+
1819
# Quickstart: Run SQL Server container images with Docker
1920

2021
[!INCLUDE[appliesto-ss-xxxx-xxxx-xxx-md-linuxonly](../includes/appliesto-ss-xxxx-xxxx-xxx-md-linuxonly.md)]
@@ -33,9 +34,11 @@ In this quickstart, you use Docker to pull and run the SQL Server 2017 container
3334

3435
In this quickstart, you use Docker to pull and run the SQL Server 2019 preview container image, [mssql-server](https://hub.docker.com/r/microsoft/mssql-server). Then connect with **sqlcmd** to create your first database and run queries.
3536

37+
> [!TIP]
38+
> This quickstart creates SQL Server 2019 preview containers. If you prefer to create SQL Server 2017 containers, see the [SQL Server 2017 version of this article](quickstart-install-connect-docker.md?view=sql-server-linux-2017).
3639
::: moniker-end
3740

38-
This image consists of SQL Server running on Linux based on Ubuntu 16.04. It can be used with the Docker Engine 1.8+ on Linux or on Docker for Mac/Windows. This quick start specifically focuses on using the SQL Server on **linux** image. The Windows image is not covered, but you can learn more about it on the [mssql-server-windows-developer Docker Hub page](https://hub.docker.com/r/microsoft/mssql-server-windows-developer/).
41+
This image consists of SQL Server running on Linux based on Ubuntu 16.04. It can be used with the Docker Engine 1.8+ on Linux or on Docker for Mac/Windows. This quickstart specifically focuses on using the SQL Server on **linux** image. The Windows image is not covered, but you can learn more about it on the [mssql-server-windows-developer Docker Hub page](https://hub.docker.com/r/microsoft/mssql-server-windows-developer/).
3942

4043
## <a id="requirements"></a> Prerequisites
4144

@@ -51,6 +54,8 @@ any changes to one section should be duplicated in the other-->
5154

5255
## <a id="pullandrun2017"></a> Pull and run the container image
5356

57+
Before starting the following steps, make sure that you have selected your preferred shell (bash, PowerShell, or cmd) at the top of this article.
58+
5459
1. Pull the SQL Server 2017 Linux container image from Microsoft Container Registry.
5560

5661
::: zone pivot="cs1-bash"
@@ -65,16 +70,23 @@ any changes to one section should be duplicated in the other-->
6570
```
6671
::: zone-end
6772

73+
::: zone pivot="cs1-cmd"
74+
```cmd
75+
docker pull mcr.microsoft.com/mssql/server:2017-latest
76+
```
77+
::: zone-end
78+
6879
> [!TIP]
6980
> If you want to try the SQL Server 2019 preview image, see the [SQL Server 2019 preview version of this article](quickstart-install-connect-docker.md?view=sql-server-linux-ver15#pullandrun2019).
7081
7182
The previous command pulls the latest SQL Server 2017 container image. 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`). To see all available images, see [the mssql-server Docker hub page](https://hub.docker.com/r/microsoft/mssql-server).
7283

84+
::: zone pivot="cs1-bash"
7385
For the bash commands in this article, `sudo` is used. On MacOS, `sudo` might not be required. 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. For more information, see [Post-installation steps for Linux](https://docs.docker.com/install/linux/linux-postinstall/).
86+
::: zone-end
7487

7588
2. To run the container image with Docker, you can use the following command from a bash shell (Linux/macOS) or elevated PowerShell command prompt.
7689

77-
7890
::: zone pivot="cs1-bash"
7991
```bash
8092
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' \
@@ -91,6 +103,14 @@ any changes to one section should be duplicated in the other-->
91103
```
92104
::: zone-end
93105

106+
::: zone pivot="cs1-cmd"
107+
```cmd
108+
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong!Passw0rd>" `
109+
-p 1433:1433 --name sql1 `
110+
-d mcr.microsoft.com/mssql/server:2017-latest
111+
```
112+
::: zone-end
113+
94114
> [!NOTE]
95115
> The password should follow the SQL Server default password policy, otherwise the container can not setup SQL server and will stop working. 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. You can examine the error log by executing the [docker logs](https://docs.docker.com/engine/reference/commandline/logs/) command.
96116
@@ -122,6 +142,12 @@ any changes to one section should be duplicated in the other-->
122142
```
123143
::: zone-end
124144

145+
::: zone pivot="cs1-cmd"
146+
```cmd
147+
docker ps -a
148+
```
149+
::: zone-end
150+
125151
You should see output similar to the following screenshot:
126152

127153
![Docker ps command output](./media/sql-server-linux-setup-docker/docker-ps-command.png)
@@ -147,42 +173,60 @@ Setting `-h` and `--name` to the same value is a good way to easily identify the
147173

148174
## <a id="pullandrun2019"></a> Pull and run the container image
149175

176+
Before starting the following steps, make sure that you have selected your preferred shell (bash, PowerShell, or cmd) at the top of this article.
177+
150178
1. Pull the SQL Server 2019 preview Linux container image from Docker Hub.
151179

152180
::: zone pivot="cs1-bash"
153181
```bash
154-
sudo docker pull mcr.microsoft.com/mssql/server:2019-CTP2.4-ubuntu
182+
sudo docker pull mcr.microsoft.com/mssql/server:2019-CTP2.5-ubuntu
155183
```
156184
::: zone-end
157185

158186
::: zone pivot="cs1-powershell"
159187
```PowerShell
160-
docker pull mcr.microsoft.com/mssql/server:2019-CTP2.4-ubuntu
188+
docker pull mcr.microsoft.com/mssql/server:2019-CTP2.5-ubuntu
189+
```
190+
::: zone-end
191+
192+
::: zone pivot="cs1-cmd"
193+
```cmd
194+
docker pull mcr.microsoft.com/mssql/server:2019-CTP2.5-ubuntu
161195
```
162196
::: zone-end
163197

164198
> [!TIP]
165199
> This quickstart uses the SQL Server 2019 preview Docker image. If you want to run the SQL Server 2017 image, see the [SQL Server 2017 version of this article](quickstart-install-connect-docker.md?view=sql-server-linux-2017#pullandrun2017).
166200
167-
The previous command pulls the latest SQL Server 2019 preview container image based on Ubuntu. To instead use container images based on RedHat, see [Run RHEL-based container images](sql-server-linux-configure-docker.md#rhel). 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`). To see all available images, see [the mssql-server-linux Docker hub page](https://hub.docker.com/_/microsoft-mssql-server).
201+
The previous command pulls the SQL Server 2019 preview container image based on Ubuntu. To instead use container images based on RedHat, see [Run RHEL-based container images](sql-server-linux-configure-docker.md#rhel). To see all available images, see [the mssql-server-linux Docker hub page](https://hub.docker.com/_/microsoft-mssql-server).
168202

203+
::: zone pivot="cs1-bash"
169204
For the bash commands in this article, `sudo` is used. On MacOS, `sudo` might not be required. 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. For more information, see [Post-installation steps for Linux](https://docs.docker.com/install/linux/linux-postinstall/).
205+
::: zone-end
170206

171207
2. To run the container image with Docker, you can use the following command from a bash shell (Linux/macOS) or elevated PowerShell command prompt.
172208

173209
::: zone pivot="cs1-bash"
174210
```bash
175211
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' \
176212
-p 1433:1433 --name sql1 \
177-
-d mcr.microsoft.com/mssql/server:2019-CTP2.4-ubuntu
213+
-d mcr.microsoft.com/mssql/server:2019-CTP2.5-ubuntu
178214
```
179215
::: zone-end
180216

181217
::: zone pivot="cs1-powershell"
182218
```PowerShell
183219
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong!Passw0rd>" `
184220
-p 1433:1433 --name sql1 `
185-
-d mcr.microsoft.com/mssql/server:2019-CTP2.4-ubuntu
221+
-d mcr.microsoft.com/mssql/server:2019-CTP2.5-ubuntu
222+
```
223+
::: zone-end
224+
225+
::: zone pivot="cs1-cmd"
226+
```cmd
227+
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong!Passw0rd>" `
228+
-p 1433:1433 --name sql1 `
229+
-d mcr.microsoft.com/mssql/server:2019-CTP2.5-ubuntu
186230
```
187231
::: zone-end
188232

@@ -200,7 +244,7 @@ Setting `-h` and `--name` to the same value is a good way to easily identify the
200244
| **-e 'SA_PASSWORD=\<YourStrong!Passw0rd\>'** | Specify your own strong password that is at least 8 characters and meets the [SQL Server password requirements](../relational-databases/security/password-policy.md). Required setting for the SQL Server image. |
201245
| **-p 1433:1433** | Map a TCP port on the host environment (first value) with a TCP port in the container (second value). In this example, SQL Server is listening on TCP 1433 in the container and this is exposed to the port, 1433, on the host. |
202246
| **--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. |
203-
| **mcr.microsoft.com/mssql/server:2019-CTP2.4-ubuntu** | The SQL Server 2019 CTP 2.4 Linux container image. |
247+
| **mcr.microsoft.com/mssql/server:2019-CTP2.5-ubuntu** | The SQL Server 2019 CTP 2.5 Linux container image. |
204248

205249
3. To view your Docker containers, use the `docker ps` command.
206250

@@ -216,6 +260,12 @@ Setting `-h` and `--name` to the same value is a good way to easily identify the
216260
```
217261
::: zone-end
218262

263+
::: zone pivot="cs1-cmd"
264+
```cmd
265+
docker ps -a
266+
```
267+
::: zone-end
268+
219269
You should see output similar to the following screenshot:
220270

221271
![Docker ps command output](./media/sql-server-linux-setup-docker/docker-ps-command.png)
@@ -244,7 +294,7 @@ The **SA** account is a system administrator on the SQL Server instance that get
244294

245295
1. Choose a strong password to use for the SA user.
246296

247-
1. Use `docker exec` to run **sqlcmd** to change the password using Transact-SQL. Replace `<YourStrong!Passw0rd>` and `<YourNewStrong!Passw0rd>` with your own password values.
297+
1. Use `docker exec` to run **sqlcmd** to change the password using Transact-SQL. In the following example, replace the old password, `<YourStrong!Passw0rd>`, and the new password, `<YourNewStrong!Passw0rd>`, with your own password values.
248298

249299
::: zone pivot="cs1-bash"
250300
```bash
@@ -262,6 +312,14 @@ The **SA** account is a system administrator on the SQL Server instance that get
262312
```
263313
::: zone-end
264314

315+
::: zone pivot="cs1-cmd"
316+
```cmd
317+
docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd `
318+
-S localhost -U SA -P "<YourStrong!Passw0rd>" `
319+
-Q "ALTER LOGIN SA WITH PASSWORD='<YourNewStrong!Passw0rd>'"
320+
```
321+
::: zone-end
322+
265323
## Connect to SQL Server
266324

267325
The following steps use the SQL Server command-line tool, **sqlcmd**, inside the container to connect to SQL Server.
@@ -280,6 +338,12 @@ The following steps use the SQL Server command-line tool, **sqlcmd**, inside the
280338
```
281339
::: zone-end
282340

341+
::: zone pivot="cs1-cmd"
342+
```cmd
343+
docker exec -it sql1 "bash"
344+
```
345+
::: zone-end
346+
283347
2. Once inside the container, connect locally with sqlcmd. Sqlcmd is not in the path by default, so you have to specify the full path.
284348

285349
```bash
@@ -379,46 +443,62 @@ The following steps use **sqlcmd** outside of your container to connect to SQL S
379443

380444
1. Find the IP address for the machine that hosts your container. On Linux, use **ifconfig** or **ip addr**. On Windows, use **ipconfig**.
381445

382-
2. Run sqlcmd specifying the IP address and the port mapped to port 1433 in your container. 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.
446+
1. For this example, install the **sqlcmd** tool on your client machine. For more information, see [Install sqlcmd on Windows](../tools/sqlcmd-utility.md) or [Install sqlcmd on Linux](sql-server-linux-setup-tools.md).
447+
448+
1. Run sqlcmd specifying the IP address and the port mapped to port 1433 in your container. 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.
383449

384450
::: zone pivot="cs1-bash"
385451
```bash
386-
sqlcmd -S 10.3.2.4,1433 -U SA -P '<YourNewStrong!Passw0rd>'
452+
sqlcmd -S <ip_address>,1433 -U SA -P '<YourNewStrong!Passw0rd>'
387453
```
388454
::: zone-end
389455

390456
::: zone pivot="cs1-powershell"
391457
```PowerShell
392-
sqlcmd -S 10.3.2.4,1433 -U SA -P "<YourNewStrong!Passw0rd>"
458+
sqlcmd -S <ip_address>,1433 -U SA -P "<YourNewStrong!Passw0rd>"
393459
```
394460
::: zone-end
395461

396-
3. Run Transact-SQL commands. When finished, type `QUIT`.
462+
::: zone pivot="cs1-cmd"
463+
```cmd
464+
sqlcmd -S <ip_address>,1433 -U SA -P "<YourNewStrong!Passw0rd>"
465+
```
466+
::: zone-end
467+
468+
1. Run Transact-SQL commands. When finished, type `QUIT`.
397469

398470
Other common tools to connect to SQL Server include:
399471

400472
- [Visual Studio Code](sql-server-linux-develop-use-vscode.md)
401473
- [SQL Server Management Studio (SSMS) on Windows](sql-server-linux-manage-ssms.md)
402474
- [Azure Data Studio](../azure-data-studio/what-is.md)
403-
- [mssql-cli (Preview)](https://blogs.technet.microsoft.com/dataplatforminsider/2017/12/12/try-mssql-cli-a-new-interactive-command-line-tool-for-sql-server/)
475+
- [mssql-cli (Preview)](https://github.com/dbcli/mssql-cli/blob/master/doc/usage_guide.md)
476+
- [PowerShell Core](sql-server-linux-manage-powershell-core.md)
404477

405478
## Remove your container
406479

407480
If you want to remove the SQL Server container used in this tutorial, run the following commands:
408481

409-
::: zone pivot="cs1-bash"
410-
```bash
482+
::: zone pivot="cs1-bash"
483+
```bash
411484
sudo docker stop sql1
412485
sudo docker rm sql1
413-
```
414-
::: zone-end
486+
```
487+
::: zone-end
415488

416-
::: zone pivot="cs1-powershell"
417-
```PowerShell
489+
::: zone pivot="cs1-powershell"
490+
```PowerShell
418491
docker stop sql1
419492
docker rm sql1
420-
```
421-
::: zone-end
493+
```
494+
::: zone-end
495+
496+
::: zone pivot="cs1-cmd"
497+
```cmd
498+
docker stop sql1
499+
docker rm sql1
500+
```
501+
::: zone-end
422502

423503
> [!WARNING]
424504
> 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](tutorial-restore-backup-in-sql-server-container.md) or use a [container data persistence technique](sql-server-linux-configure-docker.md#persist).

docs/linux/sql-server-linux-troubleshooting-guide.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ This document describes how to troubleshoot Microsoft SQL Server running on Linu
2121
> For answers to frequently asked questions, see the [SQL Server on Linux FAQ](sql-server-linux-faq.md).
2222
2323
## <a id="connection"></a> Troubleshoot connection failures
24-
If you are having difficulty connecting to your Linux SQL Server, there are a few things to check.
24+
If you are having difficulty connecting to your Linux SQL Server, there are a few things to check.
25+
26+
- If you are unable to connect locally using **localhost**, try using the IP address 127.0.0.1 instead. It is possible that **localhost** is not properly mapped to this address.
2527

2628
- Verify that the server name or IP address is reachable from your client machine.
2729

@@ -188,7 +190,7 @@ As a last resort, you can choose to rebuild the master and model databases back
188190
189191
## Improve performance
190192
191-
There are many factors that affect performance, including database design, hardware, and workload demands. If you are looking to improve performance, start by reviewing the best practices in the article, [Performance best practices and configuration guidelines for SQL Server on Linux](sql-server-linux-performance-best-practices.md). Then explore some of the avilable tools for troubleshooting performance problems.
193+
There are many factors that affect performance, including database design, hardware, and workload demands. If you are looking to improve performance, start by reviewing the best practices in the article, [Performance best practices and configuration guidelines for SQL Server on Linux](sql-server-linux-performance-best-practices.md). Then explore some of the available tools for troubleshooting performance problems.
192194
193195
- [Query Store](../relational-databases/performance/monitoring-performance-by-using-the-query-store.md)
194196
- [System dynamic management views (DMVs)](../relational-databases/system-dynamic-management-views/system-dynamic-management-views.md)

docs/zone-pivot-groups.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ groups:
99
title: Bash
1010
- id: cs1-powershell
1111
title: PowerShell
12+
- id: cs1-cmd
13+
title: Cmd
1214
- id: ld2-linux-distribution
1315
title: Linux distribution
1416
prompt: Choose your Linux distribution

0 commit comments

Comments
 (0)