Not persisting modules?

Hey everyone

After create un container of ubuntu:14:10 with :

docker run -it ubuntu:14:10

i install

apt-get git 
apt-get curl and wget 

and nvm : (https://github.com/creationix/nvm)

git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`
nvm install 0.10 

node -v (–> 0.10 work correctly )

After this i commit my container in image my_container

docker commit <container_id> my_container

but whene i run my new image “my_container”

i can’t find nvm and node ??!!

root@4f5f1ed7d3ca:/# nvm 
bash: nvm: command not found
root@4f5f1ed7d3ca:/# node 
bash: node: command not found

can someone help me to fix my problem ?

thx :slight_smile:

Hi idir,

The problem is that when the container is launched the ~/.nvm/nvm.sh file is not sourced anymore (only in your install)

In this Dockerfile I’ve exported that source command to ~/.bashrc and set the default command to /bin/bash. Then when you launch the container the nvm command is available

FROM ubuntu:14.10

RUN apt-get update && apt-get install -y curl git

RUN git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`

RUN /bin/bash -c "source ~/.nvm/nvm.sh && nvm install 0.10"

RUN echo ". ~/.nvm/nvm.sh" >> ~/.bashrc

CMD ["/bin/bash"]

After you launch a container you’ll need to specify which version you want to use:

root@4589f35e3cc9:/# nvm use 0.10
Now using node v0.10.39 (npm v1.4.28)
root@4589f35e3cc9:/# node -v
v0.10.39

thx a lot @kizbitz i will try it