当前位置: 首页 > news >正文

拉取postgresql 18.0 docker镜像并运行容器

postgresql 18.0今天发布了,在Linux上用容器来体验比较方便。
1.拉取镜像

docker pull docker.1ms.run/postgres:18
Trying to pull docker.1ms.run/postgres:18...
Getting image source signatures
Copying blob 1d5017cf452d done
Copying blob 8551209c5a1e done
Copying blob ce1261c6d567 done
Copying blob 180db792316f done
Copying blob 5773151508cd done
Copying blob 28b206cbbc14 done
Copying blob e1b18b5359f0 done
Copying blob 8d0a13cb166d done
Copying blob 30b4b10fcf1d done
Copying blob 168b3ade331e done
Copying blob 6458b7f41c65 done
Copying blob 0a51ed68fa52 done
Copying blob ef07360e404d done
Copying blob 8a9c24e23f88 done
Copying config b5a5f7a2b9 done
Writing manifest to image destination
Storing signatures
b5a5f7a2b9a2c002c1827ae45e0b136b393c74399d38272322e5da69feb8766d

2.运行容器

用以往运行其他容器的方法来运行postgresql容器报错, 查看错误日志并把错误容器删除

root@DESKTOP-59T6U68:/mnt/c/Users/lt# docker run -it -d -v /mnt/c/d:/par --net=host --name pg18 docker.1ms.run/postgres:18
e1b81df353dbf810a75ba76b99a7486aec07eab3021368605b01c6e54b2ef6ff
root@DESKTOP-59T6U68:/mnt/c/Users/lt# docker exec -it pg18 bash
Error: can only create exec sessions on running containers: container state improper
root@DESKTOP-59T6U68:/mnt/c/Users/lt# docker logs --tail 10 pg18
Error: Database is uninitialized and superuser password is not specified.You must specify POSTGRES_PASSWORD to a non-empty value for thesuperuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow allconnections without a password. This is *not* recommended.See PostgreSQL documentation about "trust":https://www.postgresql.org/docs/current/auth-trust.html
root@DESKTOP-59T6U68:/mnt/c/Users/lt# docker container rm pg18
e1b81df353dbf810a75ba76b99a7486aec07eab3021368605b01c6e54b2ef6ff

用网上看来的命令行,自己增加一些选项,还是报错

docker run -d \
--name pg18 \
-p 5432:5432 \
-e POSTGRES_PASSWORD=123456 \
-e POSTGRES_USER=postgres \
-e POSTGRES_DB=testdb \
-v /mnt/c/d:/par \
-v ~/postgresql/data:/var/lib/postgresql/data \--net=host \
docker.1ms.run/postgres:18
Port mappings have been discarded as one of the Host, Container, Pod, and None network modes are in use
Error: statfs /root/postgresql/data: no such file or directory

先建立-v选项中指定的宿主机目录,并将–net=host选项去掉,可以了

mkdir -p /root/postgresql/data
docker run -d \
--name pg18 \
-p 5432:5432 \
-e POSTGRES_PASSWORD=123456 \
-e POSTGRES_USER=postgres \
-e POSTGRES_DB=testdb \
-v /mnt/c/d:/par \
-v ~/postgresql/data:/var/lib/postgresql/data \
docker.1ms.run/postgres:18
fc33d555159907bc8a922bd3cd377dd4882ca8a3faf976785e9cde2ebe37c7e3docker exec -it pg18 bash
root@fc33d5551599:/# psql
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  role "root" does not exist
root@fc33d5551599:/# su - postgres
postgres@fc33d5551599:~$ psql
psql (18.0 (Debian 18.0-1.pgdg13+3))
Type "help" for help.postgres=#

也可以在宿主机上用psql登录容器中的数据库, 注意要指定-h选项

psql -U postgres -d testdb
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directoryIs the server running locally and accepting connections on that socket?psql -U postgres -d testdb -h localhost
Password for user postgres:
psql (14.19 (Ubuntu 14.19-0ubuntu0.22.04.1), server 18.0 (Debian 18.0-1.pgdg13+3))
WARNING: psql major version 14, server major version 18.Some psql features might not work.
Type "help" for help.
testdb=#
http://www.dtcms.com/a/411015.html

相关文章:

  • java 动态代理
  • 24届-Java开发面经-华为od
  • 开源BI系统
  • article.2034672470
  • 洞头网站建设高端品牌女装特价网
  • 天津建设网站需要的费用宜宾住房与城乡建设部网站
  • 【译】Visual Studio 中针对 .NET MAUI 的 XAML 实时预览功能的增强
  • MySQL DML 与 DQL 基础语法详解:增删改查入门实战
  • 如何把AutoDL实例里的文件备份到Github仓库?
  • 化妆品网站制作兰州h5设计
  • 论批评与自我批评
  • 建网站公司浩森宇特深圳网站建设 华信科
  • Android 13 完整实现 USB 网卡支持与网络优先级配置(USB>WiFi>4G)
  • 加强网站建设的措施莱芜中医院网站
  • 衡水企业网站设计网站上怎么做推广
  • 狄利克雷卷积
  • 沈阳 教育 公司 网站建设种子搜索网站怎么做的
  • 矩阵置零--leetcode
  • 删除iCloud中的照片但保留iPhone上的照片的两种方法
  • 巴中市住房和城乡建设局官方网站广告牌子设计图片
  • 找学校的网站塔城网站seo
  • oracle linux 10 +pg18 源码安装要点
  • 如何快速排查服务器宕机故障
  • 分sheet写入excel
  • 怎么把网站黑了传统文化网站建设
  • 【开题答辩全过程】以 SpringBootVue的旅游租车管理系统为例,包含答辩的问题和答案
  • Windows配置PicGo+Gitee图床——解决你的MarkDown笔记分享无图片的问题
  • 网站排名alexawordpress 商城安全
  • 【开题答辩过程】以《分布式菌菇销售系统》为例,不会开题答辩的可以进来看看
  • 广州优化网站关键词静态网站用什么做