title: Problems Connecting to Database within Docker Image via RStudio using DBI
body: <p>I'm attempting to connect to a database within a local Docker image I've spun up using DBI and am running into some pretty cryptic errors... I've successfully started the Docker container (below shows result of <code>docker ps -a</code>):</p>
  <pre><code>CONTAINER ID   IMAGE                                        COMMAND             CREATED          STATUS          PORTS                      NAMES
  131ab042012c   mcr.microsoft.com/mssql/server:2017-latest   &quot;/opt/mssql/bin/nonr…&quot;   27 minutes ago   Up 27 minutes   127.0.0.1:1433-&gt;1433/tcp   admiring_northcutt
  </code></pre>
  <p>I then try to connect via:</p>
  <pre><code>pool&lt;- pool::dbPool(odbc::odbc(),
                      Driver   = &quot;ODBC Driver 17 for SQL Server&quot;,
                      Server   = &quot;localhost&quot;,
                      Database = &quot;master&quot;,
                      UID      = &quot;sa&quot;,
                      PWD      = &quot;***********&quot;,
                      Port     = 1433)
  </code></pre>
  <p>and receive the error:</p>
  <pre><code>Error: nanodbc/nanodbc.cpp:1021: 00000: [Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection  [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute 
  </code></pre>
  <p>Checking my odbc driver using <code>odbc::odbcListDrivers()</code> returns the output below, so the drivers seem to be present.</p>
  <pre><code>                           name   attribute                                   value
  1 ODBC Driver 17 for SQL Server Description Microsoft ODBC Driver 17 for SQL Server
  2 ODBC Driver 17 for SQL Server      Driver    /usr/local/lib/libmsodbcsql.17.dylib
  3 ODBC Driver 17 for SQL Server  UsageCount                                       2
  </code></pre>
  <p>In addition, executing the container and attempting to connect to the database via the commands:</p>
  <pre><code>docker exec -it &lt;container-name&gt; /bin/bash
  
  /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P '&lt;password&gt;'   
  </code></pre>
  <p>EDIT: The above method now works and I'm able to actively query within the database. I know that the error can't be due to invalid login credentials because I'm using the same exact ones as I ran above in the container.</p>
  <p>This same process works for a coworker, so I'm wondering if it's a local issue with my set up. We already compared our .ini files as suggested in this link and they're identical, I've clean re-installed Docker, and I've even ran the coworker's identical container with no luck. Any ideas what could be happening here?</p>
  <p>Computer specs:</p>
  <blockquote>
  <pre><code>MacBook Pro (16-inch 2019)
  OS: macOS Monterey (version 12.2.1)
  Processor: 2.3 GHz 8-Core Intel Core i9
  Memory: 16GB 2667MHz DDR4
  Startup Disk: Macintosh HD
  Graphics: AMD Radeon Pro 5500M 4 GB
  </code></pre>
  </blockquote>
  <p>Rstudio Version: 2021.09.0 Build 351</p>
  <p>OpenSSL Version: 1.1</p>