title: Run nvm with docker exec
body: <p>I want to run nvm with <code>docker exec</code></p>
  
  <p>something like</p>
  
  <pre><code>docker run -d &lt;image&gt;
  docker exec &lt;container&gt; nvm use v6.13.0 &amp;&amp; npm install
  </code></pre>
  
  <p>but I have an error</p>
  
  <pre><code>OCI runtime exec failed: exec failed: container_linux.go:296: starting container process caused "exec: \"nvm\": executable file not found in $PATH": unknown
  </code></pre>
  
  <p>I know that I can do something like that which work</p>
  
  <pre><code>docker exec &lt;container&gt; /bin/bash -c 'source "$NVM_DIR"/nvm.sh &amp;&amp; nvm use v6.13.0'
  </code></pre>
  
  <p>But I don't want. Why ? because the point is to create a docker container usable with all my project with different version of python and node and run the <code>nvm use &lt;version&gt; &amp;&amp;  npm install</code> directly from gitlab-ci using the <code>.nvmrc</code> file into my project</p>
  
  <p>my gitlab-cy.yml run a makefile which basically run the nvm use and npm install</p>
  
  <pre><code>image: cracky5457/nvm-pyenv-yarn
  
  stages:
    - install
    - test
  
  variables:
    GITLAB_CACHING: "true"
  
  cache:
    paths:
      - pip-cache/
    key: "python_2.7"
  
  installing:
    stage: install
    script:
      - make install
    artifacts:
      paths:
        - venv/
        - node_modules/
      expire_in: 1 hour
    tags:
      - docker-runner
  </code></pre>
  
  <p>and I don't want to push <code>/bin/bash -c</code> into my makefile because the project will become docker dependent locally</p>
  
  <p>This is my docker image with the instructions to run it ( you have to create a file base_dependencies.txt, node-versions.txt, python-versions.txt ) or you can just <code>docker pull cracky5457/nvm-pyenv-yarn</code></p>
  
  <p><a href="https://hub.docker.com/r/cracky5457/nvm-pyenv-yarn/" rel="nofollow noreferrer">https://hub.docker.com/r/cracky5457/nvm-pyenv-yarn/</a></p>
  
  <pre><code>FROM phusion/baseimage:0.10.0
  
   # Make sure bash is the standard shell
  RUN rm /bin/sh &amp;&amp; ln -sf /bin/bash /bin/sh
  
  ENV ENV ~/.profile
  ENV PYENV_ROOT /root/.pyenv
  ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
  
  # Add yarn registry
  RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &amp;&amp; \
      echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
  
  # Install base system libraries.
  ENV DEBIAN_FRONTEND=noninteractive
  COPY base_dependencies.txt /base_dependencies.txt
  RUN apt-get update &amp;&amp; \
      apt-get install -y $(cat /base_dependencies.txt)
  
  # Install pyenv and default python version.
  ENV PYTHONDONTWRITEBYTECODE true
  RUN git clone https://github.com/yyuu/pyenv.git /root/.pyenv &amp;&amp; \
      cd /root/.pyenv &amp;&amp; \
      git checkout `git describe --abbrev=0 --tags` &amp;&amp; \
      eval "$(pyenv init -)"
  
  # Install nvm and default node version.
  ENV NVM_DIR /usr/local/nvm
  RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash &amp;&amp; \
      echo 'source $NVM_DIR/nvm.sh' &gt;&gt; /etc/profile
  
  # Clean up APT when done.
  RUN apt-get clean &amp;&amp; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
  
  # Install python and node versions
  COPY python-versions.txt /python-versions.txt
  RUN for version in $(cat python-versions.txt); do pyenv install $version; pyenv global $version; pip install virtualenv; done
  COPY node-versions.txt /node-versions.txt
  RUN for version in $(cat node-versions.txt); do source $NVM_DIR/nvm.sh; nvm install $version; done
  
  # Use baseimage-docker's init system.
  CMD ["/sbin/my_init"]
  </code></pre>