title: Change node version using nvm and docker-compose
body: <p>I have a Dockerfile running centos/systemd that also installs nvm and have an entrypoint.sh that runs /usr/sbin/init (as required by docs) it also accept an argument from docker-compose command to control the node version being used - BUT it seems the node version is not persistent/kept for some reason.</p>
  
  <p><strong>How can I control node version from docker-compose file?</strong></p>
  
  <p>Dockerfile:</p>
  
  <pre><code>FROM centos/systemd
  
  # Install &amp; enable httpd
  RUN yum -y update
  RUN yum -y install \
      httpd \
      autofs \
      gcc-c++ \
      make \
      git \
      fontconfig \
      bzip2 \
      libpng-devel \
      ruby \
      ruby-devel \
      zip \
      unzip
  RUN yum clean all
  RUN systemctl enable httpd.service
  
  # Setting up virtual hosts
  RUN echo "IncludeOptional apps/*.conf" &gt;&gt; /etc/httpd/conf/httpd.conf
  
  # Install nvm to later use in compose
  ENV NVM_DIR /root/.nvm
  ENV NODE_VERSION 13.10.0
  RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
  
  # install node and npm
  RUN source $NVM_DIR/nvm.sh \
      &amp;&amp; nvm install $NODE_VERSION \
      &amp;&amp; nvm install 12.16.1 \
      &amp;&amp; nvm install 11.9.0 \
      &amp;&amp; nvm install 10.9.0 \
      &amp;&amp; nvm alias default $NODE_VERSION \
      &amp;&amp; nvm use default
  
  # add node and npm to path so the commands are available
  ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
  ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
  
  # Expose ports
  EXPOSE 80
  EXPOSE 443
  
  COPY entrypoint.sh ./entrypoint.sh
  RUN chmod +x ./entrypoint.sh
  
  ENTRYPOINT ["./entrypoint.sh"]
  </code></pre>
  
  <p>entrypoint.sh:</p>
  
  <pre><code>#!/bin/bash
  source root/.nvm/nvm.sh &amp;&amp; nvm use "$@"
  node --version
  exec /usr/sbin/init
  </code></pre>
  
  <p>docker-compose:</p>
  
  <pre><code>version: '3'
  services:
    httpd:
      build: '..\Web-Server\Apache'
      privileged: true
      ports:
        - 80:80
        - 443:443
      command: 11.9.0
  </code></pre>
  
  <p>docker-compose up (output):</p>
  
  <pre><code>httpd_1  | Now using node v11.9.0 (npm v6.5.0)
  httpd_1  | v11.9.0
  </code></pre>
  
  <p>docker exec -it  /bin/sh -lc "node --version":</p>
  
  <pre><code>v13.10.0
  </code></pre>
  
  <p>Thanks!</p>