通过docker加载postgres的命令? [英] Command for loading postgres through docker?

查看:76
本文介绍了通过docker加载postgres的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道通过docker加载postgres的命令吗?以下是其文档上的推荐命令:

Does anyone know the command for loading postgres through docker? Here is the recommended command on their documentation:

docker run -it --rm --network some-network postgres psql -h some-postgres -U postgres

请忽略天真的问题,如何找到 some-network的值和 some-postgres的值? / p>

Forgive the naive question, how do you find what values for "some-network" are supposed to be and what values "some-postgres" is supposed to be?

推荐答案

好,我知道了。我的命令在技术上是正确的,但是postgres需要几秒钟来加载服务器。在这种情况下,postgres客户端才能连接到服务器!这些命令适用于我的系统:

Ok, I figured it out. My command was technically correct, but postgres takes a few seconds to load the server. The postgres client can't connect to the server until this happens! These commands worked for on my system:

docker run -e POSTGRES_PASSWORD=password  -it --rm postgres

docker ps
(get container_id from this)

docker exec -it container_id  psql -h localhost -U postgres

这篇关于通过docker加载postgres的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆