I’m VERY new to docker. This is my first experience with it. My company has Docker and my boss wants me to deploy my python web app that I created using Dash. The web app connects to Microsoft SQL Server 2017 for my databases.
I have created an image for my app but when I try to run it I get this error:
Here is also my Dockerfile and docker-compose.yml (mainly things I got from my boss and the internet.)
FROM python:3.10-slim
RUN mkdir /app
RUN pip install pipenv
COPY Pipfile* /tmp/
RUN cd /tmp && pipenv requirements > /app/requirements.txt
RUN cd /app
WORKDIR /app
RUN pip install -r /app/requirements.txt
RUN apt-get -y update && apt-get install -y curl gnupg
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
# download appropriate package for the OS version
# Debian 11
RUN curl https://packages.microsoft.com/config/debian/11/prod.list \
> /etc/apt/sources.list.d/mssql-release.list
RUN exit
RUN apt-get -y update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17
COPY . .
CMD [ "gunicorn", "--workers=6", "--timeout=100", "-b 0.0.0.0:8000", "app:app" ]
The Docker version I have is 19.03.4. I also can’t ask my boss because he’s out of the country for three weeks. He’s also not super well versed in web apps anyways.
Any help/guidance/direction would be greatly appreciated!!
I have been looking and can’t find anything that either works or I understand enough to know where to begin. Total newbie here. I don’t know if it’s a docker issue, I just didn’t know if there was something inherently wrong with the setup that could be causing it.
I don’t see anything that is Docker related and could cause this issue. It doesn’t mean that it is not Docker related but nothing indicates that.
I also had an other question. Can you answer that?
One thing that you can do is try to ping the sql server from the container and from the host. If ping is not allowed, try telnet
telnet SQLSERVERHOST_OR_IP 1433
If the connection works, then the problem must be the driver or another parameter.
Try the solution from stackoverflow that I linked in my previous post. Make sure the driver name is correct.
You can also try to run sqlcmd in a container to test the connection to the remote SQL server.
So the server connection is in the app which is in the image. But I can’t get the container to run because of the login timeout. If that’s your question.
I went down a rabbit hole and found a way to locate my server IP address for the database and I think that will help. I’m going to attempt that. Meanwhile I’ve got to integrate into a docker-compose. I’ll report back if it fixes it!
First I would check network connectivity and that nothing is blocked because of a firewall. One easy approach would be to go into the container (docker exec -it <id> sh) and try to ping the target server. If that works you can try to connect to the target server and port with something like netcat, telnet or curl.