Jenkins in previously committed docker container always start in initial setup

I’m new in Docker and Jenkins so I am not sure where is the error here. Basically I was using a docker to start a new Jenkins container, modify it, and commit (save) the work I’ve done on that container. And then I run that saved container image again but end up Jenkins in its initial setup wizard state. Here are the steps that I performed:

I run new Jenkins docker container from latest image from Jenkins

docker run -d --name Jenkins -u root -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock -v /usr/local/bin/docker:/usr/local/bin/docker jenkins/jenkins

run bash on the Jenkins container

docker exec -it -u root Jenkins /bin/bash

update packages

apt-get update

install vim

apt-get install vim

install python 3

apt-get install python3

view the log to retrieve the secret key for initial jenkins install.

docker logs Jenkins

I went to my browser to access jenkins and administer it, created and ran a pipeline, then safeExit.

Believing I’ve applied all my changes, I’ve committed to docker my changes

docker commit -m "Jenkins initial setup + vim + python3" Jenkins elmachotroso/jenkins

I really don’t need to but I still pushed in to my repository in docker hub

docker push elmachotroso/jenkins

Stop Docker Jenkins container

docker stop Jenkins
docker rm Jenkins

Run new Jenkins container using recently created image elmachotroso/jenkins

docker run -d --name Jenkins -u root -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock -v /usr/local/bin/docker:/usr/local/bin/docker elmachotroso/jenkins

At this point I’m back to Jenkins initial setup!!! 🙁
But vim and python3 I’ve installed before is there!

Source: StackOverflow