我有使用此命令的docker映像:
FROM ruby:2.4-alpine WORKDIR /usr/src/app COPY Gemfile /usr/src/app/Gemfile COPY Gemfile.lock /usr/src/app/Gemfile.lock RUN bundle config build.nokogiri --use-system-libraries RUN bundle install --without development test VOLUME /state COPY . /usr/src/app/ ENTRYPOINT ["api-entrypoint.sh"] CMD ["foreman", "start"]
它可以正确构建,但是例如当我尝试运行bash时,我得到了 container_linux.go:247: starting container process caused "exec: \"api-entrypoint.sh\": executable file not found in $PATH" docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"api- entrypoint.sh\": executable file not found in $PATH".
container_linux.go:247: starting container process caused "exec: \"api-entrypoint.sh\": executable file not found in $PATH" docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"api- entrypoint.sh\": executable file not found in $PATH".
我尝试复制入口点文件,并赋予它可执行权限,但CMD没有任何效果
CMD
/ usr / src / app可能不在您的路径中,因此您应该包括脚本的完整路径。您还需要确保entrypoint.sh是可执行的,docker将完全按照您的构建主机上的权限复制权限,因此根据您的情况,可能不需要此步骤。
FROM ruby:2.4-alpine WORKDIR /usr/src/app COPY Gemfile /usr/src/app/Gemfile COPY Gemfile.lock /usr/src/app/Gemfile.lock RUN bundle config build.nokogiri --use-system-libraries RUN bundle install --without development test VOLUME /state COPY . /usr/src/app/ RUN chmod 755 api-entrypoint.sh ENTRYPOINT ["/usr/src/app/api-entrypoint.sh"] CMD ["foreman", "start"]