Docker-在构建时安装的Ruby依赖项在容器启动时不可用



我在Dockerfile:中运行以下命令

RUN apt-get update && apt-get -y install gnupg2
RUN gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
RUN curl -sSL https://get.rvm.io | bash -s
RUN /bin/bash -l -c ". /etc/profile.d/rvm.sh && rvm install 2.3.1 && rvm use --default 2.3.1 && gem install bundler"
# some more code
ENTRYPOINT ["/entrypoint.sh"]

在我的entrypoint.sh中,我正在运行bundle install。但它抛出了一个错误:

未找到捆绑包

经过进一步调查,我发现在Docker构建期间安装的依赖项在容器运行时似乎都不可用。我可能错过了一些非常基本的东西。非常感谢您的帮助。

entrypoint.sh没有加载rvm,因此它看不到安装了rvm的Ruby或其bundler

在使用Ruby之前,通过添加. /etc/profile.d/rvm.shrvm use ..rvm加载到entrypoint.sh中。

最新更新