在Dockerfile中创build一个新的PostgreSQL用户
我需要为我在Docker
镜像中构build的PostgreSQL实例创build一个新的超级用户。 我似乎无法创build一个,这是我迄今为止尝试过的…
尝试使用“postgres”用户创build一个新的超级用户
RUN /etc/init.d/postgresql start &&\ sudo su - postgres &&\ sudo psql -U postgres --command "CREATE USER pybossa WITH SUPERUSER PASSWORD 'tester';" &&\ createdb pybossa -O pybossa > * Starting PostgreSQL 9.3 database server > ...done. >psql: FATAL: Peer authentication failed for user "postgres"
“postgres”用户默认没有密码,所以我通过--no-password
RUN /etc/init.d/postgresql start &&\ sudo su - postgres &&\ sudo psql -U postgres --no-password --command "CREATE USER pybossa WITH SUPERUSER PASSWORD 'tester';" &&\ createdb pybossa -O pybossa > * Starting PostgreSQL 9.3 database server > ...done. >psql: FATAL: Peer authentication failed for user "postgres"
所以我通过-h localhost
来禁用每个身份validation
RUN /etc/init.d/postgresql start &&\ sudo su - postgres &&\ sudo psql -U postgres -h localhost --command "CREATE USER pybossa WITH SUPERUSER PASSWORD 'tester';" &&\ createdb pybossa -O pybossa > * Starting PostgreSQL 9.3 database server > ...done. >Password for user postgres: >psql: fe_sendauth: no password supplied
最后,我尝试使用--no-password
和-h localhost
RUN /etc/init.d/postgresql start &&\ sudo su - postgres &&\ sudo psql -U postgres --no-password -h localhost --command "CREATE USER pybossa WITH SUPERUSER PASSWORD 'tester';" &&\ createdb pybossa -O pybossa > * Starting PostgreSQL 9.3 database server > ...done. >psql: fe_sendauth: no password supplied
任何帮助将非常感激!