-
-
Save joshatxantie/4bcf5d0243fba63845fce7cc40365a3a to your computer and use it in GitHub Desktop.
# syntax=docker/dockerfile:1 | |
FROM python:3.8-slim-buster | |
WORKDIR /app | |
ENV ACCEPT_EULA=Y | |
RUN apt-get update -y && apt-get update \ | |
&& apt-get install -y --no-install-recommends curl gcc g++ gnupg unixodbc-dev | |
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \ | |
&& curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list \ | |
&& apt-get update \ | |
&& apt-get install -y --no-install-recommends --allow-unauthenticated msodbcsql17 mssql-tools \ | |
&& echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile \ | |
&& echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc | |
COPY requirements.txt requirements.txt | |
RUN pip3 install -r requirements.txt | |
COPY . . | |
CMD [ "python3", "main.py" ] |
Thanks! I still struggled until I realized you have to use one of the buster versions.
This was so helpful thank you! I have implemented your suggestion in my dockerfile and was able to build the image. When I run my container i am getting the following error: /usr/bin/env: ‘bash\r’: No such file or directory. Have you experienced this error before and if so, do you have a suggestion for a fix?
Hi,
is there a solution for Windows based Docker container?
I get this errors
#11 6.209 E: Unable to locate package msodbcsql17
#11 6.209 E: Unable to locate package mssql-tools
UPDATE: I needed to add --platform
flag because I was building on Apple M1
FROM --platform=linux/amd64 python:3.9-slim-buster
THANK YOU! This not only worked for me, but made very good sense.
I'd like to add that I was creating a FastAPI REST API, and the server part of my pyodbc connection string was confusing to me.
Then I found that ...
"... in the case of Docker for Linux (standard distribution), the IP address of the host will always be 172.17. 0.1 (on the main network of docker, see comments to learn more). This is true of containers attached to the docker0 default bridge interface."
I hope this helps someone. Took me forever to figure this out.
This worked! I can't thank you enough man.
I hope this helps someone. Took me forever to figure this out.