Postgresql 隐藏Postgres查询的Docker Exec输出

Postgresql 隐藏Postgres查询的Docker Exec输出,postgresql,powershell,docker,Postgresql,Powershell,Docker,我正在使用Powershell脚本启动带有Postgres的Docker容器: docker run -p ${host_port}:${remote_port} --name $container_name -d $database_name # 0b. Wait for the container and the postgres database to be ready Do { echo "Waiting for database system to start up..."

我正在使用Powershell脚本启动带有Postgres的Docker容器:

docker run -p ${host_port}:${remote_port} --name $container_name -d $database_name

# 0b. Wait for the container and the postgres database to be ready
Do
{
    echo "Waiting for database system to start up..."
    $timeout++
    sleep 1
} until ((docker exec $container_name psql --username=$database_user_name --dbname=$database_name --command="SELECT 1;") -Or ($timeout -eq $timeout_limit))

if ($timeout -eq $timeout_limit) 
{
    Throw "Database system failed to start up."
    exit
}
else {
    # Do stuff
}
我遇到的一个问题是,在导入模式时,数据库并不总是准备就绪。我添加了Do-Until循环来继续“ping”数据库,直到它得到响应,或者直到10秒过去

这很好用。这是控制台输出:

Waiting for database system to start up...
psql: FATAL:  the database system is starting up 
Waiting for database system to start up...
有没有办法防止第二行出现

psql: FATAL:  the database system is starting up 
我尝试将“ping”重定向到
/dev/null
,但这样执行时失败

docker exec $container_name psql --username=$database_user_name --dbname=$database_name --command="SELECT 1;" > /dev/null

我想你也得重新定向Stderr。
2>&1
而不仅仅是
是如何工作的