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

Picture: Microsoft

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.

## Source:

# mssql-agent-fts-ha-tools
# Maintainers: Microsoft Corporation (twright-msft on GitHub)
# GitRepo:

# Base OS layer: Latest Ubuntu LTS
FROM ubuntu:16.04

# Install prerequistes since it is needed to get repo config for SQL server
RUN export DEBIAN_FRONTEND=noninteractive && \
    apt-get update && \
    apt-get install -yq curl apt-transport-https && \
    # Get official Microsoft repository configuration
    curl | apt-key add - && \
    curl | tee /etc/apt/sources.list.d/mssql-server.list && \
    apt-get update && \
    # Install SQL Server from apt
    apt-get install -y mssql-server && \
    # Install optional packages
    apt-get install -y mssql-server-ha && \
    apt-get install -y mssql-server-fts && \
    # Cleanup the Dockerfile
    apt-get clean && \
    rm -rf /var/lib/apt/lists

# Run SQL Server process
CMD /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:

docker 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.

docker 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 :-)