You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -86,10 +86,11 @@ The following steps increase the memory for Docker for Windows to 4 GB.
86
86
|**-e 'ACCEPT_EULA=Y'**| Set the **ACCEPT_EULA** variable to any value to confirm your acceptance of the [End-User Licensing Agreement](http://go.microsoft.com/fwlink/?LinkId=746388). Required setting for the SQL Server image. |
87
87
|**-e 'MSSQL_SA_PASSWORD=\<YourStrong!Passw0rd\>'**| Specify your own strong password that is at least 8 characters and meets [SQL Server's password requirements](../relational-databases/security/password-policy.md). Required setting for the SQL Server image. |
88
88
| **-e 'MSSQL_PID=Developer'** | Specifies the edition or product key. In this example, the freely licensed Developer Edition is used for non-production testing. For other values, see [Configure SQL Server settings with environment variables on Linux](sql-server-linux-configure-environment-variables.md). |
89
-
| **--cap-add SYS_PTRACE** | Adds the Linux capability to trace a process. This enables SQL Server to generate dumps on an exception. |
90
89
| **-p 1401: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, 1401, on the host. |
90
+
| **--name sqlcontainer1** | Specify a custom name for the container rather than a randomly generated one. If you run more than one container, you can't reuse this same name. |
91
91
|**microsoft/mssql-server-linux**| The SQL Server Linux container image. Unless otherwise specified, this defaults to the **latest** image. |
92
92
93
+
93
94
1. To view your Docker containers, use the `docker ps` command.
94
95
95
96
```bash
@@ -102,7 +103,7 @@ The following steps increase the memory for Docker for Windows to 4 GB.
102
103
103
104
1. 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. If the **STATUS** column for your SQL Server container shows **Exited**, see the [Troubleshooting section of the configuration guide](sql-server-linux-configure-docker.md#troubleshooting).
104
105
105
-
There are two useful `docker run` options not used in the previous example for simplicity. The `-h` (host name) parameter changes the internal name of the container to a custom value. This is the name you'll see returned in the following Transact-SQL query:
106
+
The `-h` (host name) parameter is also useful, but it is not used inthis tutorial forsimplicity. This changes the internal name of the container to a custom value. This is the name you'll see returnedin the following Transact-SQL query:
106
107
107
108
```sql
108
109
SELECT @@SERVERNAME,
@@ -111,33 +112,34 @@ SELECT @@SERVERNAME,
111
112
SERVERPROPERTY('ServerName')
112
113
```
113
114
114
-
You also might find the `--name` parameter useful to name your container rather than having a generated container name. Setting `-h` and `--name` to the same value is a good way to easily identify the target container.
115
+
Setting `-h` and `--name` to the same value is a good way to easily identify the target container.
115
116
116
117
## Change the SA password
117
118
118
119
The SA account is a system administrator on the SQL Server instance that gets created during setup. 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. For security purposes, change your SA password.
119
120
120
121
1. Choose a strong password to use for the SA user.
121
122
122
-
1. Use `docker exec` to run **sqlcmd** to change the password using Transact-SQL. Replace `<Old Password>` and `<New Password>` with your password values.
123
+
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.
124
+
125
+
```bash
126
+
docker exec -it sqlcontainer1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourStrong!Passw0rd>' -Q 'ALTER LOGIN SA WITH PASSWORD="<YourNewStrong!Passw0rd>"'
127
+
```
123
128
124
-
>```bash
125
-
>docker exec -it <Container ID>/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<Old Password>' -Q 'ALTER LOGIN SA WITH PASSWORD="<New Password>";'
126
-
>```
129
+
```PowerShell
130
+
docker exec -it sqlcontainer1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "<YourStrong!Passw0rd>" -Q "ALTER LOGIN SA WITH PASSWORD='<YourNewStrong!Passw0rd>'"
131
+
```
127
132
128
133
## Connect to SQL Server
129
134
130
135
The following steps use the SQL Server command-line tool, **sqlcmd**, inside the container to connect to SQL Server.
131
136
132
-
1. Use the `docker exec -it`command to start an interactive bash shell inside your running container. In the following example `e69e056c702d` is the container ID.
137
+
1. Use the `docker exec -it`command to start an interactive bash shell inside your running container. In the following example `sqlcontainer1` is name specified by the `--name` parameter when you created the container.
133
138
134
139
```bash
135
-
docker exec -it e69e056c702d"bash"
140
+
docker exec -it sqlcontainer1"bash"
136
141
```
137
142
138
-
> [!TIP]
139
-
> You don't always have to specify the entire container id. You only have to specify enough characters to uniquely identify it. So in this example, it might be enough to use `e6` or `e69` rather than the full id.
140
-
141
143
1. Once inside the container, connect locally with sqlcmd. Sqlcmd is not in the path by default, so you have to specify the full path.
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<YourStrong!Passw0rd>" -p 1401:1433 -d microsoft/mssql-server-linux
99
+
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<YourStrong!Passw0rd>" -p 1402:1433 -d microsoft/mssql-server-linux
100
100
```
101
101
102
102
Now there are two instances of SQL Server running in separate containers. Clients can connect to each SQL Server instance by using the IP address of the Docker host and the port number for the container.
@@ -123,11 +123,11 @@ Your SQL Server configuration changes and database files are persisted in the co
123
123
The first option is to mount a directory on your host as a data volume in your container. To do that, use the `docker run`command with the `-v <host directory>:/var/opt/mssql` flag. This allows the data to be restored between container executions.
This technique also enables you to share and view the files on the host outside of Docker.
@@ -140,11 +140,11 @@ This technique also enables you to share and view the files on the host outside
140
140
The second option is to use a data volume container. You can create a data volume container by specifying a volume name instead of a host directory with the `-v` parameter. The following example creates a shared data volume named **sqlvolume**.
@@ -164,6 +164,7 @@ To remove a data volume container, use the `docker volume rm` command.
164
164
> If you delete the data volume container, any SQL Server data in the container is *permanently* deleted.
165
165
166
166
### Backup and restore
167
+
167
168
In addition to these container techniques, you can also use standard SQL Server backup and restore techniques. You can use backup files to protect your data or to move the data to another SQL Server instance. For more information, see [Backup and restore SQL Server databases on Linux](sql-server-linux-backup-and-restore-database.md).
To copy a file into the container, use the following command:
209
212
210
213
```bash
@@ -307,11 +310,11 @@ If the SQL Server container fails to run, try the following tests:
307
310
- If you get an error such as **'failed to create endpoint CONTAINER_NAME on network bridge. Error starting proxy: listen tcp 0.0.0.0:1433 bind: address already in use.'**, then you are attempting to map the container port 1433 to a port that is already in use. This can happen if you're running SQL Server locally on the host machine. It can also happen if you start two SQL Server containers and try to map them both to the same host port. If this happens, use the `-p` parameter to map the container port 1433 to a different host port. For example:
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<YourStrong!Passw0rd>" -p 1400:1433 -d microsoft/mssql-server-linux`.
315
318
```
316
319
317
320
- Check to see if there are any error messages from container.
@@ -326,6 +329,14 @@ If the SQL Server container fails to run, try the following tests:
326
329
327
330
- Review the [SQL Server setup and error logs](#errorlogs).
328
331
332
+
### Enable dump captures
333
+
334
+
If the SQL Server process is failing inside the container, you should create a new container with **SYS_PTRACE** enabled. This adds the Linux capability to trace a process, which is necessary for creating a dump file on an exception. The dump file can be used by support to help troubleshoot the problem. The following docker run command enables this capability.
0 commit comments