douhuxi4145 2017-01-03 16:00
浏览 63
已采纳

/ bin / sh:1:1:gvm:找不到

Problem:

I'm attempting to create a Dockerfile that installs all the components to run Go, to install GVM (Go Version Management), and to install specific Go Versions.

Error:

When I try building the container with:

docker build -t ##### .

I get this error:

/bin/sh: 1: gvm: not found

The command '/bin/sh -c gvm install go1.4 -B' returned a non-zero code: 127

Installed here:

/root/.gvm/scripts/env/gvm
/root/.gvm/scripts/gvm
/root/.gvm/bin/gvm

What I tried:

It's clearly able to install GVM but unable to use it. Why? I thought maybe I needed to refresh the .bashrc or the .bash_profile ... but that didn't work, since they don't exist.

Dockerfile:

FROM #####/#####

#Installing Golang dependencies
RUN apt-get -y install curl git mercurial make binutils bison gcc build-essential

#Installing Golang

RUN ["/bin/bash", "-c", "bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)"]
#gvm does not exist here... why?
RUN gvm install go1.4 -B
RUN gvm use go1.4

Question:

Why does GVM not seem to be installed? How do I get rid of the error?

  • 写回答

1条回答 默认 最新

  • duanjia8215 2017-01-03 16:40
    关注

    Your shell is /bin/sh, but gvm puts its initialization in ~/.bashrc, and expects /bin/bash.

    You need to source the gvm initialization scripts to run the commands from a non-interactive bash shell:

    RUN ["/bin/bash", "-c", ". /root/.gvm/scripts/gvm && gvm install go1.4 -B"]
    RUN ["/bin/bash", "-c", ". /root/.gvm/scripts/gvm && gvm use go1.4"]
    

    Or even better might be to put the commands you want to execute in a single bash script and add that to the image.

    #!/bin/bash
    set -e
    
    source /root/.gvm/scripts/gvm
    gvm install go1.4
    gvm use go1.4
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!