[英]SQLAlchemy + pymssql - cannot connect to sql db from jupyter kernel gateway docker
我有連接到我的 sql 服務器的“sql_helper”。
db_connection = 'mssql+pymssql://{user}:{password}@{server}/{db}'.format(
user=db_user, password=db_password, server=server_name, db=db_name)
engine = sa.create_engine(db_connection)
在本地運行時,它運行良好。
然后,我將它添加到我的 jupyter kernel docker 圖像中。 這是docker 文件
# start from the jupyter image pre-installed
FROM jupyter/datascience-notebook
# install the docker
RUN pip install docker
# install the pymssql
RUN pip install pymssql
# install the kernel gateway
RUN pip install jupyter_kernel_gateway
# install the configuration helper
COPY configuration_helper-0.0.1-py3-none-any.whl /tmp/configuration_helper-0.0.1-py3-none-any.whl
RUN pip install /tmp/configuration_helper-0.0.1-py3-none-any.whl
# install the sql helper
COPY sql_helper-0.0.1-py3-none-any.whl /tmp/sql_helper-0.0.1-py3-none-any.whl
RUN pip install /tmp/sql_helper-0.0.1-py3-none-any.whl
# update enviroment variable
ENV AM_I_IN_A_DOCKER_CONTAINER Yes
EXPOSE 1433
EXPOSE 5000
# run kernel gateway on container start, not notebook server
EXPOSE 8888
CMD ["jupyter", "kernelgateway", "--KernelGatewayApp.ip=0.0.0.0", "--KernelGatewayApp.port=8888", "--KernelGatewayApp.api=kernel_gateway.notebook_http", "--KernelGatewayApp.seed_uri"]
使用以下命令運行筆記本時
docker run -it --rm -p 1433:1433 -e "ACCEPT_EULA=Y" --net=host --name ml_docker_rule_Get_prediction_rule_2 -v C:\Notebooks:/data jupyter-kernel-gateway jupyter kernelgateway --KernelGatewayApp.api='kernel_gateway.notebook_http' --KernelGatewayApp.seed_uri='/data/AOI_app_1.ipynb' --KernelGatewayApp.ip=0.0.0.0 --KernelGatewayApp.port=8901
我收到以下錯誤
Unable to connect: Adaptive Server is unavailable or does not exist (TESLADEVSQL01:1433)
我應該如何從 docker 運行它的任何幫助將不勝感激
發現問題,不用主機名需要使用sql ip
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.