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.

  • How to run script file(.sh file) inside Dockerfile? [closed]
  • Access jboss 8080 port inside docker container
  • How To run from host machine bash script inside docker container and remain in bash in container [duplicate]
  • Docker-client: How to attach user input to attachStdin at runtime
  • launch basic bash script on docker build from windows system
  • Docker push: Image depends on an unauthorized parent
  • [root@d17ae0e8bf85 /]# vim abc.txt
    bash: vim: command not found
    

    How do I go about committing the previous container where the editor was installed?

  • I am able to fetch the URL from Rancher Stack using Putty. How do I fetch the same URL from a Rancher Stack using shell commands in Jenkins
  • Determining if a process runs inside windows/iis
  • Maintaining and supporting container base images
  • What's the purpose of reexec.Init() in docker?
  • Parsing a string to an array output from command line
  • cannot generate a service account token in kubernetes v1
  • 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

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.