Laravel Sail/Docker - Unable to locate package msodbcsql17
Asked Answered
T

1

2

I'm trying to get a Laravel Sail Docker to be compatible with sqlsrv (MSSQL). I've come a long way with the config and got it to install sqlsrv and the pdo_sqlsrv. So now I need to install msodbcsql17. For that I'm following the microsoft guide (https://learn.microsoft.com/nl-nl/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15) for Ubuntu 20.04 (as that is my version).

That specific documentation says to download and run. Translating that to the Sail Dockerfile, that part of my Dockerfile looks like this:

...
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get install -y msodbcsql17 \
...

So just downloading the file and putting it in the recommended location. But no matter what I do it always comes back with a code 100: Unable to locate package msodbcsql17. So my best guess is that the location is not by default read by the apt-get install. Any suggestions are welcome.

Update: So thanks to answer, this is the solution:

...
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get install -y msodbcsql17 \
&& ACCEPT_EULA=Y apt-get install -y mssql-tools \
...
Tin answered 20/5, 2021 at 10:49 Comment(0)
D
2

By default most docker images have an empty package lists to save on image size. This is why you need to apt-get update first. This will not update any software (that would be apt-get upgrade) but just updates the package list. The command is actually also in Microsoft's instructions you linked.

Directive answered 21/5, 2021 at 6:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.