ApsaraDB / PolarDB-for-PostgreSQL

A cloud-native database based on PostgreSQL developed by Alibaba Cloud.
https://apsaradb.github.io/PolarDB-for-PostgreSQL/zh/
Apache License 2.0
2.89k stars 481 forks source link

docker拉取镜像如何指定数据库&用户 #360

Closed hxdwd closed 1 year ago

hxdwd commented 1 year ago

按照文档拉取镜像

docker run -d -p 41113:5432 \
  -it --cap-add=SYS_PTRACE \
  --restart=always \
  --privileged=true \
  --name polardb_pg_single \
  -v $PWD:/home/postgres/polardb_pg \
polardb/polardb_pg_local_instance:single

有个问题是如何指定数据库和用户密码启动,目前需要进入镜像,然后手动建库建用户,是否支持postgresSQL一样指定,例如:

docker run -d --restart=always --name=device-manager-pg \
    -p 41111:5432 \
    -v $TMP/pgdata:/var/lib/postgresql/data \
    -e POSTGRES_DB=db \
    -e POSTGRES_USER=xxx \
    -e POSTGRES_PASSWORD=xxx \
    postgres:11.2
polardb-bot[bot] commented 1 year ago

Hi @hxdwd ~ Thanks for opening this issue! 🎉

Please make sure you have provided enough information for subsequent discussion.

We will get back to you as soon as possible. ❤️

mrdrivingduck commented 1 year ago

@hxdwd Currently, we only want polardb_pg_local_instance image to be used as a quick start deployment, so that the initdb step has already been done in default during the image building. But I think what you had said is an good advice, we can let the initdb step to be done at the container starts up, so that the user of image can specify the db, user and password.

mrdrivingduck commented 1 year ago

@hxdwd We have refactored the usage of our image, now you can mount an empty directory as a volume into the container, and keep this data after the container is no longer running. Also, you can specify default user and password, like what you have said, just the same as official image of PostgreSQL. Refer to the document here.

mrdrivingduck commented 1 year ago

/close