postgres
获取postgres 镜像
postgres:15.2
创建挂载的文件夹
进入/volume1/docker/文件夹创建postgres 所需文件夹
cxloge@synocxloge:~$ cd /volume1/docker/
cxloge@synocxloge:/volume1/docker$ mkdir -p postgres/15.2/data
cxloge@synocxloge:~$ netstat -tunlp | grep 5432
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:15432 0.0.0.0:* LISTEN -
tcp6 0 0 :::15432 :::* LISTEN -
docker-cli.sh
docker run -it --name postgres-15432 \
--restart always \
-e POSTGRES_PASSWORD='YOUR_PASSWORD' \
-e ALLOW_IP_RANGE=0.0.0.0/0 \
-v $(pwd)/data:/var/lib/postgresql/data:rw \
-p 15432:5432 \
-d postgres:15.2
docker-compose.yml
cat > docker-compose.yml <<-EOF
version: "3.4"
services:
postgresql:
image: postgres:15.2
container_name: postgresql-15432
environment:
POSTGRES_DB: postgres
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "YOUR_PASSWORD"
ALLOW_IP_RANGE: "0.0.0.0/0"
ports:
- 15432:5432
volumes:
- ./data:/var/lib/postgresql/data
EOF
根据已编排好的docker-compose.yml启动容器docker-compose up -d
cxloge@synocxloge:/volume1/docker/postgres/15.2$ sudo -i
Password:
root@synocxloge:~# cd /volume1/docker/postgres/15.2
root@synocxloge:/volume1/docker/postgres/15.2# ls
data docker-compose.yml
root@synocxloge:/volume1/docker/postgres/15.2# docker-compose up -d
[+] Running 2/2
⠿ Network 152_default Created 1.3s
⠿ Container postgresql-15432 Started 4.7s
root@synocxloge:/volume1/docker/postgres/15.2# docker ps | grep postgres
5b09d5dc3f58 postgres:15.2 "docker-entrypoint.s…" 34 seconds ago Up 29 seconds 0.0.0.0:15432->5432/tcp, :::15432->5432/tcp postgresql-15432
pgadmin4
获取pgadmin4镜像
Container Deployment — pgAdmin 4 7.4 documentation
https://www.pgadmin.org/docs/pgadmin4/latest/container_deployment.html
dpage/pgadmin4:6.16
创建挂载的文件夹
进入/volume1/docker/文件夹创建pgadmin4所需文件夹
查看端口占用情况netstat -tunlp | grep 15480
cxloge@synocxloge:~$ cd /volume1/docker/
cxloge@synocxloge:/volume1/docker$ mkdir -p pgadmin4/6.16/data
docker-cli.sh
docker pull dpage/pgadmin4 \
docker run -d \
-p 15480:80 \
–name pgadmin-15480 \
-e PGADMIN_DEFAULT_EMAIL="cxloge@126.com" \
-e PGADMIN_DEFAULT_PASSWORD="YOUR_PASSWORD" \
dpage/pgadmin4:6.16
docker-compose.yml
cat > docker-compose.yml <<-EOF
version: "3.4"
services:
pgadmin:
image: dpage/pgadmin4:6.16
container_name: pgadmin-15480
environment:
PGADMIN_DEFAULT_EMAIL: "cxloge@126.com"
PGADMIN_DEFAULT_PASSWORD: "YOUR_PASSWORD"
ports:
- 15480:80
volumes:
- ./data:/var/lib/pgadmin
EOF
根据已编排好的docker-compose.yml启动容器docker-compose up -d
cxloge@synocxloge:/volume1/docker/pgadmin4/6.16$ ls
data docker-compose.yml
root@synocxloge:/volume1/docker/pgadmin4/6.16# docker-compose up -d
[+] Running 2/2
⠿ Network 616_default Created
root@synocxloge:~# docker ps | grep pgadmin
c60700e94de3 dpage/pgadmin4:6.16 "/entrypoint.sh" 3 hours ago Up 13 minutes 443/tcp, 0.0.0.0:15480->80/tcp, :::15480->80/tcp pgadmin-15480
FAQ
- [Errno 13] Permission denied: '/var/lib/pgadmin/sessions'
/pgadmin4 $ id
uid=5050(pgadmin) gid=0(root) groups=0(root)
/pgadmin4 $
修改/volume1/docker/pgadmin4
的权限sudo chown -R 5050:5050 /volume1/docker/pgadmin4
cxloge@synocxloge:/volume1/docker/pgadmin4$ pwd
/volume1/docker/pgadmin4
cxloge@synocxloge:/volume1/docker$ ll
drwxrwxrwx+ 1 cxloge users 32 Jul 8 15:57 gitea
drwxrwxrwx+ 1 root root 8 Jul 9 20:51 pgadmin4
drwxrwxrwx+ 1 cxloge users 12 Jul 9 17:27 portainer
cxloge@synocxloge:/volume1/docker$ sudo chown -R 5050:5050 /volume1/docker/pgadmin4
Password:
cxloge@synocxloge:/volume1/docker$ ll
drwxrwxrwx+ 1 cxloge users 32 Jul 8 15:57 gitea
drwxrwxrwx+ 1 5050 5050 8 Jul 9 20:51 pgadmin4
drwxrwxrwx+ 1 cxloge users 12 Jul 9 17:27 portainer
参考链接
GitHub - pgadmin-org/pgadmin4: pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL, the most advanced Open Source database in the world.
https://github.com/pgadmin-org/pgadmin4.git
GitHub - postgres/postgres: Mirror of the official PostgreSQL GIT repository. Note that this is just a mirror - we don't work with pull requests on github. To contribute, please see https://wiki.postgresql.org/wiki/Submitting_a_Patch
https://github.com/postgres/postgres.git
权限被拒绝: Docker中的‘/var/lib/pgadmin/session’
https://cloud.tencent.com/developer/ask/sof/267576/answer/419583
linux - Permission denied: '/var/lib/pgadmin/sessions' in Docker - Stack Overflow
https://stackoverflow.com/questions/64781245/permission-denied-var-lib-pgadmin-sessions-in-docker