docker postgres

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

本篇發表於 未分類。將永久鍊結加入書籤。

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>