docker 運行 postgresql
docker運行postgresql 服務(wù)端及客戶端
注意:是 postgres 不是 postgre!!!
1. orb里設(shè)置
{ "registry-mirrors" : [ "https://改成你的.mirror.aliyuncs.com", "https://docker.888666222.xyz" ], "ipv6" : true }
搜索 postgre
3. 找到相應(yīng)的版本,如16
4. 下載鏡像
docker pull postgres:16
5. 創(chuàng)建 docker network - 這是為了客戶端的訪問,也可以使用host或者暴露端口
docker network create postgres
6. 運行
docker run --it --name postgres-16 postgres:16 POSTGRES_PASSWORD=123456 -d postgres
docker run --it --name postgres-16(名字) postgres:16(image+tag) POSTGRES_PASSWORD=你要設(shè)定的密碼 -d postgres(程序)
7. 容器加入網(wǎng)絡(luò)
docker network connect postgres 容器ID
8. 查看網(wǎng)絡(luò)IP
docker network inspect postgres
9. 客戶端
# 方法一:
docker run -it --rm --network postgres postgres:16 /bin/bash
psql -h 上一步的IP -U postgres
輸入密碼
# 方法二:
docker run -it --rm --network postgres postgres:16 psql -h 上一步的IP -U postgres
浙公網(wǎng)安備 33010602011771號