docker环境下安装及使用PG数据库

1、docker环境下安装PG数据库

    dokcer pull postgres

2、启动

     docker run --name postgres -e POSTGRES_PASSWORD=123456 -p 5432:5432 -d postgres

3、进入postgres容器

   1)docker ps

[root@iZuf631wu4671bx4bhg8ycZ ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d62a6d3a32a8 postgres "docker-entrypoint.s…" 2 days ago Up 2 days 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp mypostgres

2)docker exec -it d62a6d3a32a8  bash

[root@iZuf631wu4671bx4bhg8ycZ ~]# docker exec -it d62a6d3a32a8 bash root@d62a6d3a32a8:/# ll bash: ll: command not found root@d62a6d3a32a8:/# ls bin boot dev docker-entrypoint-initdb.d etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

3)psql -U postgres

root@d62a6d3a32a8:/# psql -U postgres psql (14.5 (Debian 14.5-1.pgdg110+1)) Type "help" for help. postgres=#

你可能感兴趣的:(数据库技术,数据库开发,java,docker,postgresql,数据库)