如何在dockerized python脚本中访问presto数据库

时间:2019-06-12 20:47:31

标签: python docker presto

我正在尝试将某位工作场所某人编写的python脚本码头化,但它多次调用了我们的presto数据库。当我在本地调用脚本时,我只需要输入完整的密码即可使用,但是一旦对脚本进行了泊坞化处理就运行该脚本会导致401错误,无效的凭证。我该怎么做才能确保dockerized脚本可以访问证书?

我检查以确保presto.pem文件位于dockerized脚本的目录中,并且我知道该脚本显然正在访问presto数据库,因为这是一个凭据问题。我改成了不应该访问数据库的其他wifi,它开始给我一个不同的错误,所以我知道那不是问题。

这是我的Dockerfile:

从python:3.7

WORKDIR / app

复制。 / app

运行pip install -r requirements.txt

ENTRYPOINT [“ python”,“ app.py”,“ --website-id = 556f210de4b00a3ed267bc91”]

1 个答案:

答案 0 :(得分:0)

这似乎是网络问题。您可以查看自己的docker设置,即可解决此问题。

The host has a changing IP address (or none if you have no network access). 
From 18.03 onwards our recommendation is to connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host.
The gateway is also reachable as gateway.docker.internal

参考链接:

Access host database from a docker container

https://docs.docker.com/engine/reference/commandline/run/