How to update a running docker image and save the state

  1. Run the desired updates/installs. For example:
# from host
docker exec -it rocker /bin/bash

# inside container
sudo apt-get update
sudo apt-get install -y curl

exit
  1. Now, get the rrunning CONTAINER ID and use it to commit the image.
# from host
docker ps

# find the running CONTAINER ID, use it in next step
docker commit acc7d32fd061 rocker/tidyverse:4.1.1

# you have now saved it!