title: Setting up docker image with R and SQL server drivers
body: <p>This is probably going to be an underspecified question, but as I’ve spent close to two days trying to get it to work I figured I might give it a try:</p>
  
  <p>I am trying to set up a docker image that can comminicate with a SQL Server db through R (either using RODBC or odbc)</p>
  
  <p>The problem I keep encountering seems to be that I fail to install (or locate) the neccisary SQL server drivers when establishing a connection, when running: </p>
  
  <pre><code> con &lt;- dbConnect(odbc(),
               Driver = "SQL Server",
               Server = "xxxx",
               Database = "xxxx",
               UID = "xxx",
               PWD = “xxxx")
  </code></pre>
  
  <p>Has anyone set up a similar Docker image ?</p>
  
  <p>EDIT:</p>
  
  <p>Here is my current dockerfile (I have tried multiple things but this one reproduces the error message)</p>
  
  <pre><code>    FROM rocker/r-ver:3.5.0
  
      RUN apt-get -qq update \
          &amp;&amp; apt-get -qq dist-upgrade -y \
          &amp;&amp; apt-get -qq install git unixodbc unixodbc-dev postgresql-9.5 odbc-postgresql libssl-dev sudo -y
  
      COPY . /usr/local/src/myscripts
      WORKDIR /usr/local/src/myscripts
  
      RUN R -e 'install.packages("odbc")'
      RUN R -e 'install.packages("plumber")'
  
      EXPOSE 8000
  
      CMD ["Rscript", "plumber.R"]
  </code></pre>
  
  <p>And running the container and executing odbc commands gives:</p>
  
  <pre><code>    &gt; library('odbc')
      &gt; con &lt;- dbConnect(odbc(),
      +                    Driver = "SQL Server",
      +                    Server = "xx",
      +                    Database = "xx",
      +                    UID = "xx",
      +                    PWD = "xx")
      Error: nanodbc/nanodbc.cpp:950: 01000: [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found
  </code></pre>