记录:在docker中运行PostgreSQL
docker     PostgreSQL     发布于 12/06/2020 13:08:58   527次围观  0条评论
docker    PostgreSQL    发表于 12/06/2020 13:08:58   527人围观  0条评论
``` //1拉取镜像 docker pull postgres:12.1 //2创建数据卷 docker volume create dv_pgdata //3启动容器 docker run --name my_postgres -v dv_pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=xxxxxx -p 5432:5432 -d postgres:12.1 //账号是:postgres //4. 这时候查看已存在的docker volume: docker volume ls ``` ``` docker run -it --name postgres --restart always -e POSTGRES_PASSWORD='abc123' -e ALLOW_IP_RANGE=0.0.0.0/0 -v /home/postgres/data:/var/lib/postgresql -p 55433:5432 -d postgres ``` 5查看volume信息: ``` [root@VM_0_6_centos _data]# docker inspect dv_pgdata [ { "CreatedAt": "2020-01-14T08:40:03+08:00", "Driver": "local", "Labels": {}, "Mountpoint": "/var/lib/docker/volumes/dv_pgdata/_data", "Name": "dv_pgdata", "Options": {}, "Scope": "local" } ] [root@VM_0_6_centos _data]# cd /var/lib/docker/volumes/dv_pgdata/_data [root@VM_0_6_centos _data]# ll total 132 drwx------ 19 polkitd ssh_keys 4096 Jan 14 08:40 . drwxr-xr-x 3 root root 4096 Jan 14 08:33 .. drwx------ 5 polkitd ssh_keys 4096 Jan 14 08:38 base drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:38 global drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:38 pg_commit_ts drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:38 pg_dynshmem -rw------- 1 polkitd ssh_keys 4535 Jan 14 08:38 pg_hba.conf -rw------- 1 polkitd ssh_keys 1636 Jan 14 08:38 pg_ident.conf drwx------ 4 polkitd ssh_keys 4096 Jan 14 08:45 pg_logical drwx------ 4 polkitd ssh_keys 4096 Jan 14 08:38 pg_multixact drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:40 pg_notify drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:38 pg_replslot drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:38 pg_serial drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:38 pg_snapshots drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:40 pg_stat drwx------ 2 polkitd ssh_keys 4096 Jan 14 16:44 pg_stat_tmp drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:38 pg_subtrans drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:38 pg_tblspc drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:38 pg_twophase -rw------- 1 polkitd ssh_keys 3 Jan 14 08:38 PG_VERSION drwx------ 3 polkitd ssh_keys 4096 Jan 14 08:38 pg_wal drwx------ 2 polkitd ssh_keys 4096 Jan 14 08:38 pg_xact -rw------- 1 polkitd ssh_keys 88 Jan 14 08:38 postgresql.auto.conf -rw------- 1 polkitd ssh_keys 26588 Jan 14 08:38 postgresql.conf -rw------- 1 polkitd ssh_keys 36 Jan 14 08:40 postmaster.opts -rw------- 1 polkitd ssh_keys 94 Jan 14 08:40 postmaster.pid ``` 查看postgresql: ``` [root@VM_0_6_centos ~]#docker exec -it 618 bash root@618f1a4128ee:/# psql -U postgres psql (12.1 (Debian 12.1-1.pgdg100+1)) Type "help" for help. postgres=# ``` 安装管理器 ``` docker pull dpage/pgadmin4:4.17 docker run --name pgadmin -p 5080:80 \\ -e 'PGADMIN_DEFAULT_EMAIL=pekkle@abc.com' \\ -e 'PGADMIN_DEFAULT_PASSWORD=xxxxxx' \\ -e 'PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION=True' \\ -e 'PGADMIN_CONFIG_LOGIN_BANNER="Authorised users only!"' \\ -e 'PGADMIN_CONFIG_CONSOLE_LOG_LEVEL=10' \\ -d dpage/pgadmin4:4.17 ```
立即登录,发表评论
没有帐号?立即注册
{{$.post.CommentNum}} 条评论