我目前正在学习 docker 并尝试使用 PostgreSQL 数据库运行 docker 容器。我成功了一次,一切似乎都很顺利。一段时间后,我尝试运行另一个具有几乎相同设置的 Docker 容器,但是,它没有按预期进行。我的问题是,现在,每当我尝试运行 PostgreSQL 容器时,initdb都会以“信任”模式初始化数据库,并接受任何没有密码的连接。
\n到目前为止,我已经尝试从控制台运行命令:
\ndocker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 32000:5432 -d postgres:14.5-alpine\nRun Code Online (Sandbox Code Playgroud)\n以及运行docker-compose.yaml:
\nservices:\n db:\n container_name: Test_container\n image: postgres:14.5-alpine\n restart: unless-stopped\n ports:\n - "32000:5432"\n environment:\n POSTGRES_USER: postgres\n POSTGRES_PASSWORD: mysecretpassword\nRun Code Online (Sandbox Code Playgroud)\n此外,我尝试以不同的方式排序标签、不同的图像和不同的值,清理docker:删除所有容器、图像和卷,甚至重新安装docker,但是,每当我检查新创建的容器的日志时,我都会得到:
\nsh: locale: not found\n2022-08-16 09:35:50.709 UTC [30] WARNING: no usable system locales were found\nperforming post-bootstrap initialization ... ok\ninitdb: warning: enabling "trust" authentication for local connections\nYou can change this by editing …Run Code Online (Sandbox Code Playgroud)