This add-on quickly installs the MS SQL server into a DDEV project. It is based on the mcr.microsoft.com/mssql/server image.
Warning: the mssql-docker image does not natively work on Apple Silicon (arm64). However, this version of the add-on is able to use the Microsoft amd64 images where Rosetta 2 is installed, enabled, and configured in your Docker provider.
On ARM64/Apple Silicon machines, make sure to use a Docker provider with Rosetta 2 support enabled.
ddev add-on get ddev/ddev-sqlsrv
ddev restart
After installation, make sure to commit the .ddev directory to version control.
| Command | Description |
|---|---|
ddev sqlcmd |
For Transact-SQL statements, system procedures, and script files. See examples for T-SQL statements in ddev help sqlcmd |
ddev drupal-regex |
For compatibility with Drupal version 9 or higher |
ddev describe |
Describe the SQL Server container and its configuration |
ddev logs -s sqlsrv |
View the SQL Server container logs |
Drupal CMS needs the database function installed that is mimicking the Regex function as Drupal requires. As a one-time setup for Drupal, install the database function by running the following command from your project’s directory:
ddev drupal-regex
This script also changes the setting for the following database variables:
show advanced options will be set to 1clr strict security will be set to 0clr enable will be set to 1Drupal also required the sqlsrv module to be installed as it is provides the database driver for SQL Server. The module can be installed with composer with the following command:
ddev composer require drupal/sqlsrv
If you don’t want the default database engine to run, add omit_containers[db] to your .ddev/config.yaml.
See Config Options for additional notes.
You can the Sqlsrv server to host port for use by host-side applications. This is not useful for PHP applications that operate inside the container, and it means you can only run one project using ddev-sqlsrv at a time.
Add a docker-compose.sqlsrv_extra.yaml with:
services:
sqlsrv:
ports:
- "${MSSQL_EXTERNAL_PORT:-1433}:1433"
and set an alternate bind port like 1499 instead of 1433:
ddev dotenv set .ddev/.env.sqlsrv --mssql-external-port=1499
ddev add-on get ddev/ddev-sqlsrv
ddev restart
Commit the .ddev/.env.sqlsrv and docker-compose.sqlsrv_extra.yaml files to version control.
To change the password:
ddev dotenv set .ddev/.env.sqlsrv --mssql-sa-password='myNewPassword'
ddev add-on get ddev/ddev-sqlsrv
ddev restart
Make sure to commit the .ddev/.env.sqlsrv file to version control.
All customization options (use with caution):
| Variable | Flag | Default |
|---|---|---|
MSSQL_DOCKER_IMAGE |
--mssql-docker-image |
mcr.microsoft.com/mssql/server:2022-CU17-ubuntu-22.04 |
MSSQL_EXTERNAL_PORT |
--mssql-external-port |
1433 |
MSSQL_SA_PASSWORD |
--mssql-sa-password |
Password12! |
MSSQL_PID |
--mssql-pid |
Evaluation |
MSSQL_DB_NAME |
--mssql-db-name |
master |
MSSQL_HOST |
--mssql-host |
sqlsrv |
MSSQL_COLLATION |
--mssql-collation |
LATIN1_GENERAL_100_CI_AS_SC_UTF8 |
Note that more advanced techniques are discussed in DDEV docs.
Contributed and maintained by @robertoperuzzo based on the original ddev-contrib recipe by drupal-daffie