无法在docker镜像中使用sdkman安装groovy

时间:2016-11-23 12:25:07

标签: docker groovy sdk

我使用脚本来构建dockerfile。下面是我的剧本...

echo "FROM ubuntu:14.04" >> Dockerfile
echo "RUN rm /bin/sh && ln -s /bin/bash /bin/sh" >> Dockerfile
echo "RUN apt-get -y update && apt-get upgrade -y" >> Dockerfile
echo "RUN apt-get install -y software-properties-common" >> Dockerfile
echo "RUN apt-get -y update && add-apt-repository -y ppa:webupd8team/java" >> Dockerfile 
echo "RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections" >> Dockerfile
echo "RUN echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections" >> Dockerfile 
echo "RUN apt-get -y update && apt-get install -y oracle-java8-installer" >> Dockerfile
echo "RUN apt-get install -y curl " >> Dockerfile
echo "RUN apt-get install -y unzip " >> Dockerfile
echo "RUN apt-get -y update && curl -s get.sdkman.io | bash" >> Dockerfile
echo 'RUN source "$HOME/.sdkman/bin/sdkman-init.sh"' >> Dockerfile
echo 'RUN source ~/.profile' >> Dockerfile
echo "RUN yes | sdk install groovy" >> Dockerfile
...
docker build -t imagename:version ./
...
  

但我收到以下错误

RUN yes | sdk install groovy
 ---> Running in 09056add5ab7
/bin/sh: sdk: command not found
The command '/bin/sh -c yes | sdk install groovy' returned a non-zero code: 127
  

如果我不使用这个命令“sdk install groovy”,那么构建是成功的。然后我运行图像并发出相同的命令,它可以工作。

任何帮助,任何想法为什么这是hapenning?

1 个答案:

答案 0 :(得分:2)

RUN yes | /bin/bash -l -c 'sdk install groovy' 

的工作。