2017-01-03 16:00
浏览 44

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


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.


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:


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.


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"]
#gvm does not exist here... why?
RUN gvm install go1.4 -B
RUN gvm use go1.4


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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanjia8215
    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.

    set -e
    source /root/.gvm/scripts/gvm
    gvm install go1.4
    gvm use go1.4
    点赞 评论