gpt4 book ai didi

docker - 使用Dockerfile运行命令时出错

转载 作者:行者123 更新时间:2023-12-02 18:33:10 24 4
gpt4 key购买 nike

我正在尝试使用this tutorial将rbenv安装在centos容器中。
当我自己在bash中运行这些命令时,它们可以工作,但是当使用docker build时,出现以下错误。

FROM centos:latest

RUN yum install -y sudo git vim git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel

RUN cd
RUN git clone git://github.com/sstephenson/rbenv.git .rbenv
RUN echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
RUN echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
RUN exec $SHELL

RUN git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
RUN echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
RUN exec $SHELL
RUN source ~/.bash_profile

RUN rbenv install -v 2.2.1
RUN rbenv global 2.2.1

RUN echo "gem: --no-document" > ~/.gemrc

RUN gem install bundler

输出
Step 9 : RUN exec $SHELL
---> Running in 021180fff90b
---> 62ed2f1faaa6
Removing intermediate container 021180fff90b
Step 10 : RUN source ~/.bash_profile
---> Running in 89e10052c73b
/root/.bash_profile: line 14: rbenv: command not found
---> f819228f98c2
Removing intermediate container 89e10052c73b
Step 11 : RUN rbenv install -v 2.2.1
---> Running in a4304fe37e18
/bin/sh: rbenv: command not found
The command '/bin/sh -c rbenv install -v 2.2.1' returned a non-zero code: 127

我究竟做错了什么?

最佳答案

您的源命令在RUN中,因此在下一个命令中将其忘记

关于docker - 使用Dockerfile运行命令时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32582989/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com