Skip to content

Instantly share code, notes, and snippets.

@pbthorste
Last active July 4, 2025 09:53
Show Gist options
  • Save pbthorste/2dd302939ad84ab26932e9e18b7428d8 to your computer and use it in GitHub Desktop.
Save pbthorste/2dd302939ad84ab26932e9e18b7428d8 to your computer and use it in GitHub Desktop.
Docker image with msssql 2022 with full text search enabled
# Docker image with msssql 2022 with full text search enabled
# based on work in: https://github.com/Microsoft/mssql-docker
# Base OS layer: Latest Ubuntu LTS
FROM --platform=linux/amd64 ubuntu:focal
# 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 gnupg && \
# Get official Microsoft repository configuration
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb --output packages-microsoft-prod.deb && dpkg -i packages-microsoft-prod.deb && \
curl https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2022.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-fts && \
ACCEPT_EULA=Y apt-get install -y mssql-tools && \
# Cleanup the Dockerfile
apt-get clean && \
rm -rf /var/lib/apt/lists
# Run SQL Server process
CMD /opt/mssql/bin/sqlservr
@chrisstraw
Copy link

I've been struggling to get a Dockerfile to work. Your file worked great. Thanks!

@matthewdavisdev
Copy link

What a king. Much appreciated.

@AliHadiOzturk
Copy link

You're saver. Thansk!

@apiscevs
Copy link

Thanks a lot, I've been struggling for several hours without any success.

@ArcadeMode
Copy link

Thanks for sharing this!

@smstuebe
Copy link

smstuebe commented Jul 4, 2025

I had an issue with the certificates of packages.microsoft.com. So I added installing the certificates.

FROM mcr.microsoft.com/mssql/server:2022-latest

# Switch to root to install fulltext - apt-get won't work unless you switch users!
USER root

# Install dependencies - these are required to make changes to apt-get below
RUN apt-get update && \
    apt-get install -yq gnupg gnupg2 gnupg1 ca-certificates curl apt-transport-https && \
# download certificate chain for packages.microsoft.com
    openssl s_client -showcerts -connect packages.microsoft.com:443 -servername packages.microsoft.com </dev/null 2>/dev/null | \
        awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/ { print $0 }' > msft-chain.pem && \
# Split the certificate chain into individual certificates
    awk 'split_after == 1 {n++;split_after=0} /END CERTIFICATE/ {split_after=1} {print > "msft-cert" n ".crt"}' < msft-chain.pem && \
#install the certificates into the system
    cp msft-cert*.crt /usr/local/share/ca-certificates/ && \
# refresh the certificate store
    update-ca-certificates && \
# Install SQL Server package links - why aren't these already embedded in the image?  How weird.
    curl https://packages.microsoft.com/keys/microsoft.asc -o /var/opt/mssql/ms-key.cer && \
    apt-key add /var/opt/mssql/ms-key.cer && \
    curl https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list -o /etc/apt/sources.list.d/mssql-server-2022.list && \
    apt-get update && \
# Install SQL Server full-text-search - this only works if you add the packages references into apt-get above
    apt-get install -y mssql-server-fts && \
# Cleanup - remove the links to Microsoft packages that we added earlier
    apt-get clean && \
    rm -rf /var/lib/apt/lists

# Run SQL Server process
ENTRYPOINT [ "/opt/mssql/bin/sqlservr" ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment