SQL Server in Docker with fulltext Search support

Container Jun 21, 2021

By default, there is currently no Full-Text Search Support in the Docker Images for Microsoft SQL Serverby 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.

But we have luck, others have already thought about it:

The Microsoft MSSQL Docker samples shows a Dockerfile that provides full-text support.

## Source: https://github.com/Microsoft/mssql-docker/blob/master/linux/preview/examples/mssql-agent-fts-ha-tools/Dockerfile

# mssql-agent-fts-ha-tools
# Maintainers: Microsoft Corporation (twright-msft on GitHub)
# GitRepo: https://github.com/Microsoft/mssql-docker

# 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 https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
    curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2019.list | 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

Lets create the Image

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

Here a example command for generating the image

docker build -t beejay/mssql-fts:ubuntu .

After the build ist complete, it will shown up in the docker images list

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. Also I try to use an external volume to mount the Database to an persistent volume (D:\sql1\data).

docker run --name mssqlfts -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=YourPass123#" -e "MSSQL_AGENT_ENABLED=true" -p 60666:1433 -v D:\sql1\data:/var/opt/mssql/data -d beejay/mssql-fts:ubuntu

After running this command the SQL server will be available at port 60666 (yea 666... because it can be a hell 😉).

Restarting the container

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

The MSSQL Docker Container can now be used with Full-Text Search Support 😃

Tags