docker run --restart=always --name mypostgresql -v /var/docker/postgres/data:/home/data/ -v /var/docker/postgres/conf:/var/lib/postgresql -e POSTGRES_PASSWORD=xxxxxx -d -p 15432:5432 postgres 

其中 --name your-postgresql 指的是你的postgresql容器的名字,

 

-v /var/docker/postgres/data:/home/data/的意思是-v 你电脑上的目录/你容器内的目录:

~/Docker/your-postgresql/data是我linux系统存放.sql文件方便容器读取的目录;

/home/data是postgresql容器自带的目录,

这样设置是为了避免权限导致出错,postgresql容器有些目录是只读的,无法写入文件。

如果配错了目录映射会在你想要进行数据库备份、导入/导出时遇到报错:Read-only file system

-e POSTGRES_PASSWORD=xxxxxx的意思是你的数据库密码;

-p 5432:5432 是映射端口;

配置后可以通过5432端口远程连接电脑的5432端口链接到postgresql容器。

相关文章:

  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-04-18
  • 2021-11-08
  • 2021-05-18
  • 2021-08-01
猜你喜欢
  • 2021-07-04
  • 2022-12-23
  • 2021-11-23
  • 2021-11-01
  • 2022-01-13
  • 2021-08-14
  • 2021-12-26
相关资源
相似解决方案