So, here is the working of the docker container; docker images build and work in layers when the docker image is built every command adds a layer to the docker image in your case ubuntu is a docker image so when you create a container and when you make changes in container your changes are saved in a writable layer above base image you use which is ubuntu in your case. When you commit the changes along with the new layer it is saved with the new changes as a layer on top of the base ubuntu layer.
Docker image layers are saved with only metadata of the changes made so the changes made are just reflected but the underneath layers still exist this is the reason why when you delete a gaint file from container and form a new image size of the image is not reduced as on ly changes are saved. This is done for space optimization lets say 5 containers use ubuntu as base image so ubuntu is not downloaded 5 times, instead same base image is used but the layers above it have info of the changes so the top most layer of the image is used.
So when you make changes to the ubuntu container the changes are not updated In the image you used to build the container or anywhere in the host system unless volumes configurations are set. The info of the changes are saved in the writable layer of the container and these get deleted when container is removed and are not reflected if a new container is made using the same ubuntu image this is what it means when its said that containers are stateless. If you wish your data to persist you can either commit the changes made after creating the container or you can mount volumes while creating the container for you data to persist.
more info on volumes can be found here:- manage docker data