Skip to content

Instantly share code, notes, and snippets.

@ggpinto
Created January 31, 2022 10:25
Show Gist options
  • Select an option

  • Save ggpinto/b4a82a92743410357b770d7c242076b5 to your computer and use it in GitHub Desktop.

Select an option

Save ggpinto/b4a82a92743410357b770d7c242076b5 to your computer and use it in GitHub Desktop.
Dockerfile for rocker/tidyverse:4.1.2 with Microsoft SQL Server
FROM rocker/tidyverse:4.1.2
# making sure that all packages will be versioned
RUN R -e "options(repos = list(CRAN = 'https://mran.microsoft.com/snapshot/2022-01-30'))"
# install some packages needed for odbc
RUN apt-get update && apt-get install -y \
curl \
apt-utils \
apt-transport-https \
debconf-utils \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# adding custom MS repository
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
# install SQL Server drivers and tools
RUN apt-get update && ACCEPT_EULA=Y apt-get -y install msodbcsql17 mssql-tools
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
RUN /bin/bash -c "source ~/.bashrc"
# install needed packages
RUN R -e "install.packages('odbc')"
@ggpinto
Copy link
Author

ggpinto commented Jan 31, 2022

Based on this gist and this blog post. Don't forget to use Driver = ODBC Driver 17 for SQL Server for the connection string.

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