Committing an interactive container in docker
I am trying to install the vim editor on bash in the centOS container in docker. However, as soon as I am exiting the container, I am losing my progress. Is there a way where I can commit the container after I am done with downloading the editor?
This is what I am doing:
user@personal-pc:~/Desktop$ sudo docker run -i -t centos /bin/bash [root@9c0f428c4907 /]# yum install vim
After the installation is done, the editor works perfectly. However, when I end this running session, and run bash again, then the editor does not exist.
[root@d17ae0e8bf85 /]# vim abc.txt bash: vim: command not found
How do I go about committing the previous container where the editor was installed?
2 Solutions collect form web for “Committing an interactive container in docker”
when I end this running session
-> so now, you do
docker commit 1234 mycontainer , if you start a new interactive session, you lose what you did before
commit the container 9c0f428c4907 with a new name.(After installing vim)
Eg: docker commit 9c0f428c4907 centos_viminstalled
Now run this cnetos_viminstalled image in a container
docker run -i -t cnetos_viminstalled /bin/bash
You will be able to see that vim is installed in this new image centos_viminstalled