如何修复 bin/sh: can't create /etc/sysctl.conf: Permission denied when 运行 docker-compose?

How to fix bin/sh: can't create /etc/sysctl.conf: Permission denied when running docker-compose?

我打算使用 Laravel 并且我想使用 laradock。在一些成功的设置过程之后。

我本来想 运行 docker-compose up 但我收到了这个错误

Building ide-theia
Step 1/3 : FROM theiaide/theia
 ---> 40a7b9da8cae
Step 2/3 : LABEL maintainer="ahkui <ahkui@outlook.com>"
 ---> Using cache
 ---> d9d45043f719
Step 3/3 : RUN echo 'fs.inotify.max_user_watches=524288' >> /etc/sysctl.conf
 ---> Running in 4dd5bcc59773
/bin/sh: can't create /etc/sysctl.conf: Permission denied
ERROR: Service 'ide-theia' failed to build: The command '/bin/sh -c echo 'fs.inotify.max_user_watches=524288' >> /etc/sysctl.conf' returned a non-zero code: 1

我不知道为什么。不管我用了没用sudo,还是报错

这是一个 known & fixed Laradock 问题。
你应该 update Laradock.

我刚刚找到了修复它的方法。转到 Laradock 文件夹 > ide-theia > Dockerfile。添加此命令

USER root

在此命令之前

RUN echo 'fs.inotify.max_user_watches=524288' >> /etc/sysctl.conf

保存,再尝试运行docker-compose up

查看此问题已在 https://github.com/laradock/laradock/commit/df49e2fd83c15cb11691b03673f5d432a8cbafd6?fbclid=IwAR2z2z0EfOdP6bVd-ZIRIkE158HfKxXrB9pdNwqD0NYD9B7tRY3rKMCaDEA

处修复