docker环境下搭建使用postgresql10

1.查看镜像库中postgres镜像

[root@localhost ~]# docker search postgres
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
postgres The PostgreSQL object-relational database sy… 5278 [OK]
sameersbn/postgresql 132 [OK]
paintedfox/postgresql A docker image for running Postgresql. 77 [OK]
orchardup/postgresql https://github.com/orchardup/docker-postgres… 46 [OK]
kiasaki/alpine-postgres PostgreSQL docker image based on Alpine Linux 42 [OK]
centos/postgresql-96-centos7 PostgreSQL is an advanced Object-Relational … 24
bitnami/postgresql Bitnami PostgreSQL Docker Image 20 [OK]
begriffs/postgrest Moved to https://hub.docker.com/r/postgrest/… 16 [OK]
centos/postgresql-94-centos7 PostgreSQL is an advanced Object-Relational … 15
crunchydata/crunchy-postgres Crunchy PostgreSQL is an open source, unmodi… 12
schickling/postgres-backup-s3 Backup PostgresSQL to S3 (supports periodic … 12 [OK]
wrouesnel/postgres_exporter Postgres metrics exporter for Prometheus. 9
circleci/postgres The PostgreSQL object-relational database sy… 8
clkao/postgres-plv8 Docker image for running PLV8 1.4 on Postgre… 8 [OK]
postdock/postgres PostgreSQL server image, can work in master … 7 [OK]
centos/postgresql-95-centos7 PostgreSQL is an advanced Object-Relational … 5
blacklabelops/postgres Postgres Image for Atlassian Applications 4 [OK]
camptocamp/postgresql Camptocamp PostgreSQL Docker Image 3 [OK]
frodenas/postgresql A Docker Image for PostgreSQL 3 [OK]
ansibleplaybookbundle/rds-postgres-apb An APB that deploys an RDS instance of Postg… 0 [OK]
cfcommunity/postgresql-base https://github.com/cloudfoundry-community/po… 0
fredboat/postgres PostgreSQL 10.0 used in FredBoat’s docker-co… 0
relatable/postgrest Nginx container to serve web requests to the… 0 [OK]
ansibleplaybookbundle/postgresql-apb An APB which deploys RHSCL PostgreSQL 0 [OK]
cfcommunity/postgresql https://github.com/cloudfoundry-community/po… 0

2.下载镜像

docker pull postgres

3.查看镜像

docker images

root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
postgres latest 978b82dc00dc 10 days ago 236MB
4.启动一个postgres镜像的容器

docker run --name postgres1 -e POSTGRES_PASSWORD=password -p 54321:5432 -d postgres

5.查看运行容器 docker ps -a

[root@localhost bin]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c54aa1dca256 postgres “docker-entrypoint.s…” 10 seconds ago Up 3 seconds 0.0.0.0:54321->5432/tcp postgres1

6.使用psql登录,确认成功。

[root@localhost bin]# ./psql -U postgres -h localhost -p 54321
Password for user postgres:
psql.bin (9.5.0.5, server 10.4 (Debian 10.4-2.pgdg90+1))
WARNING: psql.bin major version 9.5, server major version 10.4.
Some psql features might not work.
Type “help” for help.

postgres=# select version();
version

PostgreSQL 10.4 (Debian 10.4-2.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit
(1 row)

postgres=#

参考文献:https://hub.docker.com/_/postgres/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值