docker search -f=stars=10 postgres
#搜尋10顆星以上
docker volume create –name postgresql-data
docker run -d -p 5432:5432 –name mypostgres –restart always -v postgresql-data:/var/lib/postgresql/data -e POSTGRES_PASSWORD=0000 postgres
-d :後台執行 Container ,並返回ID
-p 5432:5432 :將 Container 的 5432 Port 映射到主機的 5432 Port (前面代表主機,後面代表容器)
-name mypostgres :將 Container 取名為 mypostgres
-restart always :container 重新啟動 container
-v postgresql-data:/var/lib/postgresql/data :使用剛建立的volume,postgresql-data 掛載到 Container 的 /var/lib/postgresql/data。
postgres :指定安裝的鏡像postgres
#進入 Container
docker exec -it mypostgres bash
參考 https://morosedog.gitlab.io/docker-20190505-docker12/
https://docs.postgresql.tw/tutorial