【发布时间】:2020-08-18 18:44:49
【问题描述】:
我正在 Ubuntu 18.04 上构建 Rails 应用程序,并尝试使用 docker 设置应用程序的部署。
我有 2 个入口点文件:
- docker/entrypoints/docker-entrypoint.sh
- docker/entrypoints/sidekiq-entrypoint.sh
通常,要使文件可执行,我必须在主机终端中运行以下命令:
chmod +x docker/entrypoints/docker-entrypoint.sh
chmod +x docker/entrypoints/sidekiq-entrypoint.sh
但是,我希望在 Dockerfile 中实现这一点,而不必总是在主机的终端上进行。
为此,我在 Dockerfile 中添加了以下命令:
RUN chmod +x docker/entrypoints/docker-entrypoint.sh \
chmod +x docker/entrypoints/sidekiq-entrypoint.sh
ENTRYPOINT ["./docker/entrypoints/docker-entrypoint.sh"]
但后来我遇到了这个错误:
chmod: 无法访问 'chmod': 没有这样的文件或目录
chmod: 无法访问 '+x': 没有这样的文件或目录
错误:服务“应用程序”构建失败:命令“/bin/sh -c chmod +x docker/entrypoints/docker-entrypoint.sh chmod +x docker/entrypoints/sidekiq-entrypoint.sh”返回非-零代码:1
我尝试了一些解决方案,但到目前为止都没有奏效。任何形式的帮助都将不胜感激。
【问题讨论】:
-
您需要在两个命令之间添加一些标点符号,
RUN chmod ... && chmod ...。反斜杠换行符插入空格,但实际上并没有终止第一个chmod命令。 -
虽然您的解决方案解决了问题,但命令中有错误。它应该是
chmod -x file && chmod -x another file在你的情况下命令读取chmod +x file1 chmod +x file2因为没有 chmod 或 +x 文件,它只会失败 -
@Stefano,我认为命令应该是
chmod +x file1 chmod +x file2而不是chmod -x file && chmod -x another file,因为我正在使文件可执行。如果我要撤销文件的权限,它将是chmod -x file && chmod -x another file。 -
谢谢@DavidMaze,您能否通过更清晰的示例详细说明您的答案。
-
这是一个错字。我的意思是+x
标签: ruby-on-rails bash shell docker sh