Saving current container in docker

I started a ubuntu container in docker and installed some new packages, edited some files and made it so that I can work with it in the future.

Now it I stop accidently delete the container, all my modifications will be lost.

In order to make sure the modifications are saved and I can reuse the same image as and when I need, you need to save the image in your docker account

1
docker commit <containerid> lalitmehta/<container_name>

Any time you need to pull the saved image and run, follow the following step:

1
docker run -ti --entrypoint=sh --name=<name> -p 8081:80 lalitmehta/<container_name>