Use a MSSQL Server 2017 Docker Container with Full-Text Search Support

Use a MSSQL Server 2017 Docker Container with Full-Text Search Support

By default, there is currently no Full-Text Search Support in the Docker Images for Microsoft SQL Server 2017 or 2019 by Microsoft. The only option currently available is to create your own Docker Image, which includes Full-Text Search in the form of the MSSQL Agent.

Fortunately, others have already thought about it: the Microsoft MSSQL Docker samples shows a Dockerfile that provides full-text support.

 1## Source: https://github.com/Microsoft/mssql-docker/blob/master/linux/preview/examples/mssql-agent-fts-ha-tools/Dockerfile
 2
 3# mssql-agent-fts-ha-tools
 4# Maintainers: Microsoft Corporation (twright-msft on GitHub)
 5# GitRepo: https://github.com/Microsoft/mssql-docker
 6
 7# Base OS layer: Latest Ubuntu LTS
 8FROM ubuntu:16.04
 9
10# Install prerequistes since it is needed to get repo config for SQL server
11RUN export DEBIAN_FRONTEND=noninteractive && \
12    apt-get update && \
13    apt-get install -yq curl apt-transport-https && \
14    # Get official Microsoft repository configuration
15    curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
16    curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list | tee /etc/apt/sources.list.d/mssql-server.list && \
17    apt-get update && \
18    # Install SQL Server from apt
19    apt-get install -y mssql-server && \
20    # Install optional packages
21    apt-get install -y mssql-server-ha && \
22    apt-get install -y mssql-server-fts && \
23    # Cleanup the Dockerfile
24    apt-get clean && \
25    rm -rf /var/lib/apt/lists
26
27# Run SQL Server process
28CMD /opt/mssql/bin/sqlservr

Create the image

Save this snippet into a Dockerfile and create an image with a tag of your choice. For example:

1docker build -t benjaminabt/mssql-fts:2017-ubuntu .

After a few minutes, depending on how fast your internet and your PC is, your image should be listed under the command docker images.

Run the image

The Docker Container can now be created. It is a best to assign a name directly, so that starting and stopping later is easier. Make sure to include the additional argument -e "MSSQL_AGENT_ENABLED=true". This also starts the agent that provides full-text support.

1docker run --name mssql -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=YourPass123#" -e "MSSQL_AGENT_ENABLED=true" -p 1401:1433 -d benjaminabt/mssql-fts:2017-ubuntu

In this case, the container can be reached via port 1401.

To start the Docker Container just type docker start mssql; to stop it just use docker stop mssql.

Note: on Windows, the command line uses double quotes("). On Linux, single quotes (’) are used.

The MSSQL Server 2017 Docker Container can now be used with Full-Text Search Support :-)


Comments

Twitter Facebook LinkedIn WhatsApp