使用Dockerfile运行命令时出错

时间:2015-09-15 09:53:49

标签: docker dockerfile

我正在尝试使用this tutorial在一个centos容器中安装rbenv。 当我在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

我做错了什么?

1 个答案:

答案 0 :(得分:1)

您的源命令处于RUN状态,因此在下一个命令中会忘记它

相关问题