本文介绍了Docker:chmod:无法访问'chmod':没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Ubuntu 18.04上构建 Rails 应用程序,并且尝试使用docker设置应用程序的部署。

I am building a Rails application on Ubuntu 18.04 and I trying to set up the deployment of the application using docker.

我有2个入口点文件:


  • docker / entrypoints / docker-entrypoint.sh

  • docker / entrypoints / sidekiq -entrypoint.sh

通常,要使文件可执行,我必须在主机终端中运行以下命令:

Usually, to make the files executable, I have to run the commands below in my host machine terminal:

chmod +x docker/entrypoints/docker-entrypoint.sh
chmod +x docker/entrypoints/sidekiq-entrypoint.sh

但是,我想在Dockerfile中实现这一点,而不必总是在主机的终端上完成。

However, I would like to make this possible in the Dockerfile, without having to always do it on the host machine's terminal.

为此,我在Dockerfile中添加了以下命令:

For this, I added the command below in the Dockerfile:

RUN chmod +x docker/entrypoints/docker-entrypoint.sh \
    chmod +x docker/entrypoints/sidekiq-entrypoint.sh
ENTRYPOINT ["./docker/entrypoints/docker-entrypoint.sh"]

但是随后我遇到此错误:

But then I run into this error:

chmod:无法访问'+ x':没有这样的文件或目录

chmod: cannot access '+x': No such file or directory

错误:服务'app '无法构建:命令'/ bin / sh -c chmod + x docker / entrypoints / docker-entrypoint.sh chmod + x docker / entrypoints / sidekiq-entrypoint.sh'返回了非零代码:1

ERROR: Service 'app' failed to build: The command '/bin/sh -c chmod +x docker/entrypoints/docker-entrypoint.sh chmod +x docker/entrypoints/sidekiq-entrypoint.sh' returned a non-zero code: 1

我尝试了几种解决方案,但到目前为止都没有。任何形式的帮助都将不胜感激。

I have tried a few solutions, but none has worked so far. Any form of help would be gladly appreciated.

推荐答案

这是我解决问题的方式

只需从以下位置更改 Dockerfile 中的命令:

Simply change the command in the Dockerfile from:

RUN chmod +x docker/entrypoints/docker-entrypoint.sh \
    chmod +x docker/entrypoints/sidekiq-entrypoint.sh
ENTRYPOINT ["./docker/entrypoints/docker-entrypoint.sh"]

为此:

RUN ["chmod", "+x", "/docker/entrypoints/docker-entrypoint.sh"] \
    ["chmod", "+x", "/docker/entrypoints/sidekiq-entrypoint.sh"]
ENTRYPOINT ["./docker/entrypoints/docker-entrypoint.sh"]

此外,请尝试将 docker-entrypoint.sh 复制/复制到工作目录。以下任何一种方法都可以做到:

Also, endeavour to see that you copy/copied the docker-entrypoint.sh to your working directory. Any of the following will do it:

# Copy other project files
COPY . ./

# Docker init
RUN ["chmod", "+x", "docker-entrypoint.sh"]
ENTRYPOINT ["./docker-entrypoint.sh"]

OR

# Copy docker entrypoint file
COPY docker-entrypoint.sh ./

# Docker init
RUN ["chmod", "+x", "docker-entrypoint.sh"]
ENTRYPOINT ["./docker-entrypoint.sh"]

OR

# Copy docker entrypoint file
COPY /docker/docker-entrypoint.sh ./docker/docker-entrypoint.sh

# Docker init
RUN ["chmod", "+x", "docker/docker-entrypoint.sh"]
ENTRYPOINT ["./docker/docker-entrypoint.sh"]

注意:这取决于位置 docker-entrypoint.sh 以及将其复制到的位置。

Note: This depends on the location of your docker-entrypoint.sh and where you was to copy it to.

仅此而已。

我希望这会有所帮助

这篇关于Docker:chmod:无法访问'chmod':没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 14:15