简体   繁体   English

如何在我的 docker 容器中运行 Postgres 查询?

[英]How do I run a Postgres query inside my docker container?

I'm using a Windows machine with Postgres 9.5 installed.我正在使用安装了 Postgres 9.5 的 Windows 机器。 I've also got a Docker container.我还有一个 Docker 容器。 I need to run an sql file located specifically inside my docker container, and it's supposed to run the query on Window's Postgres.我需要运行一个 sql 文件,该文件专门位于我的 docker 容器内,它应该在 Window 的 Postgres 上运行查询。

How can I do this either using my docker file or my init.sh file (which is called from the docker file).如何使用我的 docker 文件或我的 init.sh 文件(从 docker 文件调用)来执行此操作。

According to the discussion, the main problem is the connection timeout, and we can increase the connection timeout.根据讨论,主要问题是连接超时,我们可以增加连接超时。

See the official documentation https://www.postgresql.org/docs/9.6/runtime-config-client.html见官方文档https://www.postgresql.org/docs/9.6/runtime-config-client.html

Here is an example of it working这是它工作的一个例子

SET statement_timeout = 10000;
SET
test=# SELECT pg_sleep(15);
ERROR:  canceling statement due to statement timeout

for more info, you can have a look to this: https://dba.stackexchange.com/questions/164419/is-it-possible-to-limit-timeout-on-postgres-server有关更多信息,您可以查看以下内容: https://dba.stackexchange.com/questions/164419/is-it-possible-to-limit-timeout-on-postgres-server

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何设置 docker-compose.yml、Express 和 TypeORM 以将我的 Express 服务器连接到容器内的 Postgres 数据库? - How do I set up docker-compose.yml, Express and TypeORM to connect my Express server to a Postgres db inside the container? 如何使用 FastApi 端点或另一个 docker 容器上的 python 脚本查询在 docker 容器上运行的 postgres 数据库? - How do i query a postgres database running on docker container using a FastApi endpoint or python script on another docker container? 如何从 docker 容器 postgres:12 中读取 csv 文件? - How do I read a csv file from inside a docker container postgres:12? 如何将我的数据保存在 docker/postgres 容器中? - How can i persist my data in docker/postgres container? 如何从外部 CLI 连接到 Docker Postgres 容器? - How do I connect to Docker Postgres Container from an Outside CLI? 如何在 docker Alpine Linux 容器中运行 Postgres? - How to run Postgres in a docker Alpine Linux container? 无法在 postgres docker 容器内运行 psql 命令 - Unable to run psql command inside a postgres docker container 在docker-compose中,如何将一个容器中的应用程序连接到另一个容器中的Postgres数据库 - In docker-compose, how do I connect an app in one container to a postgres db in another container docker容器启动后如何运行bash脚本? - How do I run a bash script in a docker container after it starts? 如何查看在docker容器中配置的postgres数据库的数据? - How can I see the data of postgres database configured inside the docker container?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM