The approach desribed is the way to “update” a container (actualy replace it):
– pull latest image
– remove old container
– create or run new container using the same arguments as the old container
Background info: a container is always based on an exact image (identified by it’s sha256 checksum) - this can not be changed afterwards. That’s why the old container needs to be removed and a new container (based on the new image) needs to be created.
This pretty much depends wether you mapped volumes from the host inside the container to persist permanent data outside the container or not. If done right there is no need to export anyting. If the curent container is configured wrong, things will be way more complicated and chances to lose data are high.
It depends: do you happen to have created your container using a compose file? In that case the whole update procedure would be simply
docker-compose pull && docker-compose up -d (note: if persistant data is mapped in volumes!). docker-compose deployments always replace containers where contiguration changes/new images are detected.
I highly recommend to make yourself aquainted with docker-compose if you haven’t already as it will make life much easer.