简体   繁体   中英

Using Docker and PostgreSQL: How can I set administrator password in official postgresql image? (But securely, not a living environment variable)

I am using the official PostgreSQL Docker image ( postgresql:11-alpine ) from Docker HUB registry.

I want to create the PostgreSQL administrator password in a safe way.

Currently, this image offer to set it using environment variable :

在此处输入图片说明

Using environment variables is not really safe as it can be seen after initialization by anyone having access to the host.

There is another option for setting the password but that only work in docker swarm.

In this image, how can I set the PostgreSQL administrator, securely, and without manual step during initial deployment?

One quick suggestion will be

Use the environment variable password and then Bash into container and change the password using

postgres=# \password

Enter new password:
Enter it again:
postgres=#

Or Create a Docker FILE which does

Get the Image RUN with ENVIRONMENT password Bash into and change the pwd via initialization script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM