Raphael Haddad
Raphael Haddad

Reputation: 86

MSSQL tools on Ubuntu (20.10) Docker Image on M1 MacBook

on my M1 MacbookPro I have created a Dockerfile below:

FROM ubuntu:20.10

RUN apt-get update
RUN apt-get install -y curl gnupg2

RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

RUN curl https://packages.microsoft.com/config/ubuntu/20.10/prod.list > /etc/apt/sources.list.d/mssql-release.list

RUN exit
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17

RUN ACCEPT_EULA=Y apt-get install -y mssql-tools
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
RUN source ~/.bashrc

It uses the Ubuntu 20.10 image, and attempts to install Microsoft's ODBC Driver. I have followed the commands as per Microsoft's documentation.

When I run a build, I get an error Unable to locate package msodbcsql17. I have tried running and SSHing into the container and I still get the same error.

% docker build .           
[+] Building 5.3s (11/14)                                                                                                                                                                    
 => [internal] load build definition from Dockerfile                                                                                                                                    0.4s
 => => transferring dockerfile: 37B                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                       0.5s
 => => transferring context: 2B                                                                                                                                                         0.0s
 => [internal] load metadata for docker.io/library/ubuntu:20.10                                                                                                                         2.8s
 => [ 1/11] FROM docker.io/library/ubuntu:20.10@sha256:6b603b0f3b8fc71b1a97bd38e081e8df04793f1447362c12385b48106aaded3f                                                                 0.0s
 => CACHED [ 2/11] RUN apt-get update                                                                                                                                                   0.0s
 => CACHED [ 3/11] RUN apt-get install -y curl gnupg2                                                                                                                                   0.0s
 => CACHED [ 4/11] RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -                                                                                           0.0s
 => CACHED [ 5/11] RUN curl https://packages.microsoft.com/config/ubuntu/20.10/prod.list > /etc/apt/sources.list.d/mssql-release.list                                                   0.0s
 => CACHED [ 6/11] RUN exit                                                                                                                                                             0.0s
 => CACHED [ 7/11] RUN apt-get update                                                                                                                                                   0.0s
 => ERROR [ 8/11] RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17                                                                                                                      1.8s
------                                                                                                                                                                                       
 > [ 8/11] RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17:                                                                                                                                 
#11 0.893 Reading package lists...                                                                                                                                                           
#11 1.278 Building dependency tree...                                                                                                                                                        
#11 1.347 Reading state information...
#11 1.394 E: Unable to locate package msodbcsql17
------
executor failed running [/bin/sh -c ACCEPT_EULA=Y apt-get install -y msodbcsql17]: exit code: 100

Upvotes: 7

Views: 5736

Answers (2)

Johnd90
Johnd90

Reputation: 303

I had a similar issue to the one above and found that the problem was due to there being no msodbcsql17 package available for arm64 architecture(M1 Mac). The solution was to change the base image at the start of the docker file to

FROM --platform=linux/amd64 python:3.8.6

Or in your case

FROM --platform=linux/amd64 ubuntu:20.10

Upvotes: 20

Ritik Prapann
Ritik Prapann

Reputation: 11

From your error[Unable to locate package msodbcsql17 ] Find the following link.

https://github.com/MicrosoftDocs/sql-docs/issues/6494

Upvotes: 0

Related Questions