Connect to Microsoft SQL Database using official tools

petter.olsson Member, Moderator, Domino Posts: 78 mod
edited November 2019 in Tutorials & Best Practices


As we have seen pymssql not being developed for a while due to Microsoft open sourcing these tools we can now use this Dockerfile to have native MS SQL Client support in Linux. This describes Ubuntu (Specifically 16.04) but can very easily be changed.

#Gives you Sudo access in container
RUN echo "ubuntu    ALL=NOPASSWD: ALL" >> /etc/sudoers

# SQL Server Command Line Tools
LABEL maintainer="Domino Data Lab"

# apt-get and system utilities
RUN apt-get update && apt-get install -y update-manager-core apt dpkg curl apt-transport-https debconf-utils
RUN rm -rf /var/lib/apt/lists/*

# adding custom MS repository - change Ubuntu version here as needed
RUN curl | apt-key add -
RUN curl > /etc/apt/sources.list.d/mssql-release.list

# install SQL Server drivers and tools
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17 mssql-tools
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
RUN /bin/bash -c "source ~/.bashrc"

USER ubuntu 
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
RUN /bin/bash -c "source ~/.bashrc"

USER root
RUN apt-get -y install locales
RUN locale-gen en_US.UTF-8
RUN update-locale LANG=en_US.UTF-8

CMD /bin/bash

There are several environment variables you optionally can set up to store secure information about your MSSQL connection. Set the following as Domino environment variables on your user account:


For more information on how-to use the sqlcmd itself we suggest the following read:

Have a powerful day!


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!