加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – pg_restore到在docker容器中运行的postgres

发布时间:2020-12-13 16:08:07 所属栏目:百科 来源:网络整理
导读:我有一个数据库的备份,我将恢复到在docker容器内运行的postgres数据库. 我在OS X上使用docker-machine. Postgres图像是postgres:9.4. 这是我到目前为止提出的脚本: pg_restore --verbose --clean --no-acl --no-owner -h tcp://`docker-machine ip defau
我有一个数据库的备份,我将恢复到在docker容器内运行的postgres数据库.

我在OS X上使用docker-machine.
Postgres图像是postgres:9.4.

这是我到目前为止提出的脚本:

pg_restore --verbose --clean --no-acl --no-owner 
  -h tcp://`docker-machine ip default`:5432 
  -U postgres 
  -d tonsser-api_development latest.dump

但这不起作用.我收到错误:

pg_restore: connecting to database for restore
pg_restore: [archiver (db)] connection to database "tonsser-api_development" failed: could not translate host name "tcp://192.168.99.100:5432" to address: nodename nor servname provided,or not known

解决方法

似乎没有适当的解决方案在运行时执行此操作,但是将dumpfile复制到容器:

docker cp dumpfile DBcontainer:/dumpfile

并从容器内恢复:

docker  exec -i -t DBcontainer /bin/bash
psql DBname < dumpfile

一次性使用效果很好……

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读