Save Changes in Containers
If you make changes within a container, such as installing updates, additional toolboxes, or add-ons, you can save the container for later use. You can then deploy the updated version of the container, without needing to install the updates or toolboxes again.
Perform these steps after you have made your changes in the container and while the container is still running.
If you are using a remote Docker host, on your client machine, open another connection to the Docker host, the machine running the container, using PuTTY or the same method you used to access the Docker host and launch the container. If, instead, you are using a local Docker host, open a new shell.
In the new shell or connection, obtain the container ID of the running container using the following command.
To save the container, use the
docker commit command.
docker commit <containerID> <repository>:<tag>
docker commitcommand locally saves a new container image based on the specified container ID; in this case, based on the currently running container. You can view the images available locally using the
As an example, suppose you are using MATLAB® R2020a in a MATLAB Container. You have updated MATLAB in the container you are running currently, and you want to save it for later use.
First, find the container ID of the running container.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3d555451f07a nvcr.io/partners/matlab:r2020a "/bin/run.sh" 24 minutes ago Up 24 minutes 0.0.0.0:5901->5901/tcp, 0.0.0.0:6080->6080/tcp relaxed_pasteur
Next, commit the container image.
docker commit 3d555451f07a mymatlab:r2020a