容器来源于使用官方Dockerfile build的镜像 https://github.com/docker-library/postgres/tree/master/10
环境:CentOS 7
文件列表
-rw-r--r--. 1 root root 3962 Apr 8 17:13 docker-entrypoint.sh
-rw-r--r--. 1 root root 5649 Apr 8 17:13 Dockerfile
build成功后运行,报错:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"docker-entrypoint.sh\": executable file not found in $PATH": unknown.
ERRO[0000] error waiting for container: context canceled
报错信息为 docker-entrypoint.sh 执行文件找不到,经过一番折腾,发现在build镜像时docker-entrypoint.sh没有执行权限。
解决办法:
1、更改文件权限
# chmod +x docker-entrypoint.sh
2、重新build镜像
# docker build -t postgres:10.3 .
3、运行容器
# docker run postgres:10.3
运行成功
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
参考资料:https://stackoverflow.com/questions/27158840/docker-executable-file-not-found-in-path
本文解决了一个常见的Docker启动PostgreSQL容器时出现的错误:docker-entrypoint.sh执行文件未找到。通过调整文件权限并重新构建镜像,成功启动了PostgreSQL容器。

977

被折叠的 条评论
为什么被折叠?



