When using Ostinato for Containerlab, you might want to save and restore your Ostinato session across lab restarts.
This guide is specific for Containerlab. See the guide for GNS3 EVE-NG or CML if you are using those platforms.
As we know containers are ephemeral by design. When you destroy a container, all its data is lost.
Unless, you mount a host directory as a volume to the container!
Here’s what you need to do in 4 easy steps.
Step 1 - Edit clab.yml file
Edit the Ostinato node section in your clab.yml
file to add a volume mount (called bind in containerlab).
. . .
topology:
nodes:
ost:
kind: linux
image: ostinato/ostinato:{tag}
ports:
- 5900:5900/tcp
- 7878:7878/tcp
binds:
- .:/root/shared
. . .
The above bind configuration mounts the host current directory .
as a volume to the container. Inside the container it can be accessed at /root/shared
.
Run (or restart) the lab with the usual clab (re)deploy
command.
Step 2 - Configure Ostinato and save session file
Configure Ostinato using the GUI as usual.
Then use File | Save Session to save the Ostinato session configuration to a file. Make sure you save it in the /root/shared
directory.
If you make further changes to the Ostinato session, you can save it again to the same file.
Step 3 - Destroy lab and verify session file is saved
When you destroy the lab, the session file will remain saved on the host’s current directory - you can run ls
to verify.
Step 4 - Run lab again and restore session
Next time you run the lab, use File | Open Session from the Ostinato GUI to open the session file from the same /root/shared
directory.
All the Ostinato configuration will be restored.
That’s all there is to it!
You can now destroy and re-deploy your lab as many times as you want without losing your Ostinato session - just remember to save the session file in the /root/shared
directory.
A future Ostinato version will auto save the session configuration file so that you don’t have to remember to do it.