无法使用entrypoint.sh删除容器中的文件

我扩展了官方的postgres-9.5图像,在图像中使用转储来启动预填充的容器。 我扩展了entrypoint.sh以执行一些post-init命令,旨在清除重垃圾。

postgres total 427632 drwxr-xr-x 2 postgres postgres 4096 May 1 15:46 . drwxr-xr-x 59 root root 4096 May 1 15:54 .. -rw-r--r-- 1 postgres postgres 437876014 Apr 27 07:42 dump.sql -rw-rw-r-- 1 postgres postgres 236 Apr 27 20:20 init-user-db.sh rm: cannot remove '/docker-entrypoint-initdb.d/': Permission denied 

然而,我不明白为什么我的部分失败了,也许是由于Docker的内部机制,使得它在这个阶段是只读的,即使是从文件的所有者(第一行是一个whoami)…但如果我去根与docker执行官我可以手动删除它们。

这不是一个阻塞问题,但我找不到任何文件回答我。

编辑:按照要求,这里是我添加到入口点上面的输出

 echo echo 'PostgreSQL init process complete; ready for start up.' echo # Cleanup => user=postgresql whoami ls -la /docker-entrypoint-initdb.d/ rm -rf /docker-entrypoint-initdb.d/ echo 'Removed init files' 

Dockerfile

 FROM postgres:9.5 LABEL maintainer "Hiruma" ADD nightly-dump/ /docker-entrypoint-initdb.d/ ADD init-user-db.sh /docker-entrypoint-initdb.d/init-user-db.sh RUN chown -R postgres:postgres /docker-entrypoint-initdb.d/ ENTRYPOINT ["docker-entrypoint.sh"] EXPOSE 5432 CMD ["postgres"]