docker pull postgres:13
docker images
docker run --name postgres -e POSTGRES_PASSWORD=shen -p 5432:5432 -d postgres
查看容器
docker container ps -a
注意:拉取最新的镜像
version: '3'
services:
postgres:
image: postgres:latest
container_name: pg
volumes:
- ./data:/var/lib/postgresql/data
environment:
POSTGRES_USER: shen
POSTGRES_DB: postgre
POSTGRES_PASSWORD: shen
ports:
- "5432:5432"
执行
docker-compose run -d
docker exec -it 9fb80da40a9e /bin/bash
psql -U shen