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=#

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐