rfswift container commit
Save a container’s current state as a new image.
rfswift container commit saves a container’s current state as a new image: every tool you installed and every file you changed inside it. Use it to keep a setup you spent time on, to take a snapshot before a risky change, or to share a customised environment.
rfswift container commit -c my_sdr_work -i my_sdr_backupYou can then create new containers from that image with rfswift container create -i my_sdr_backup -n NAME.
Other spellings: the legacy form rfswift commit still works and prints a notice. The flags are the same. See the command tree.
Synopsis
rfswift container commit -c CONTAINER_NAME -i NEW_IMAGE_NAMEOptions
| Flag | Description | Required | Example |
|---|---|---|---|
-c, --container STRING |
Container to commit | Yes | -c my_container |
-i, --image STRING |
Name for new image | Yes | -i my_backup:v1 |
Container picker: without -c in an interactive terminal, RF Swift shows a container picker. If you also leave out -i, it suggests an image name based on the container’s current image (or rfswift/committed:latest).
Examples
Basic usage
Create backup image
rfswift container commit -c my_sdr_work -i my_sdr_backupWith version tag
rfswift container commit -c assessment -i assessment_backup:v1.0Before removing container
# Save state first
rfswift container commit -c temp_container -i saved_state
# Safe to remove now
rfswift container rm -c temp_container
# Can recreate later
rfswift container create -i saved_state -n restored_containerEveryday cases
Save configured environment
# You spent hours configuring tools
rfswift container shell -c sdr_work
# ... install additional tools, configure settings ...
exit
# Save all that work
rfswift container commit -c sdr_work -i sdr_configured:2024_01Create project snapshot
# End of assessment phase
rfswift container commit -c client_assessment -i client_assessment_phase1:final
# Continue to phase 2
rfswift container shell -c client_assessment
# ... more work ...
exit
# Save phase 2
rfswift container commit -c client_assessment -i client_assessment_phase2:finalShare custom environment with team
# Create customized environment
rfswift container commit -c my_setup -i team_sdr_environment:v1
# Export the image to a file you can share
rfswift image export image -i team_sdr_environment:v1 -o sdr_backup.tar.gz
# (or export the container itself)
rfswift image export container -c my_setup -o sdr_backup.tar.gz
# Team members import the file
rfswift image import image -i sdr_backup.tar.gzBefore major changes
# Checkpoint before risky operation
rfswift container commit -c production_monitor -i production_monitor_backup:pre_upgrade
# Try upgrade
rfswift container shell -c production_monitor
# ... attempt upgrade ...
# ... something breaks ...
exit
# Restore from backup
rfswift container rm -c production_monitor
rfswift container create -i production_monitor_backup:pre_upgrade -n production_monitorCreate versioned snapshots
# Daily snapshots during project
rfswift container commit -c research_container -i research_project:day_1
# ... work ...
rfswift container commit -c research_container -i research_project:day_2
# ... work ...
rfswift container commit -c research_container -i research_project:day_3
# Can return to any day's state
rfswift container create -i research_project:day_2 -n restore_day_2What gets committed
Captured in image
What the new image contains:
| Content | Included? | Notes |
|---|---|---|
| Container filesystem changes | Yes | All modifications to files |
| Installed packages | Yes | APT, pip, npm packages |
| Configuration files | Yes | Modified configs in container |
| Created files | Yes | Scripts, data files, logs |
| Environment variables | Partial | Runtime variables are not kept |
| Running processes | No | Only filesystem, not RAM |
| Mounted volumes | No | Volume data not in image |
| Network configuration | Partial | Basic settings only |
| Port bindings | No | Set them again on the new container |
Example of what’s saved
# Inside container
rfswift container shell -c my_container
# Changes that WILL be in committed image:
apt-get install -y new-tool # Saved
pip3 install additional-package # Saved
echo "alias ll='ls -la'" >> ~/.bashrc # Saved
mkdir /root/my-scripts # Saved
cp tool.py /usr/local/bin/ # Saved
# Changes that WON'T be in committed image:
# Data in mounted volumes # Not saved
# Running processes # Not saved
# Temporary /tmp files may not persist # Depends
exit
rfswift container commit -c my_container -i my_configured_imageMounted volumes
Mounted folders are not included. Files in a folder you mounted from your computer (with -b) stay on your computer and are not copied into the image. To include them, copy them into the container’s own filesystem before committing, or back them up separately:
# Create container with volume
rfswift container create -i sdr_full -n capture_work \
-b ~/captures:/root/captures
# Inside container
rfswift container shell -c capture_work
# Files in /root/captures are on host (~/captures)
# Files in /root/other are in container filesystem
exit
# Commit
rfswift container commit -c capture_work -i capture_backup
# New container from committed image
rfswift container create -i capture_backup -n restored
rfswift container shell -c restored
ls /root/captures # Empty! (no volume mounted)
ls /root/other # Present! (was in container filesystem)
exit
# Need to mount volume again
rfswift container rm -c restored
rfswift container create -i capture_backup -n restored -b ~/captures:/root/capturesTroubleshooting
Container not found
The error message is: Error: No such container: container_name
To fix it:
# List containers
rfswift container lastImage name already exists
The error message is: Error: Conflict: Tag already exists
To fix it:
# Option 1: Use different tag
rfswift container commit -c container -i image:v2
# Option 2: Remove the old image first
rfswift image rm -i image:v1
rfswift container commit -c container -i image:v1Related commands
container create: create containers from a committed imageimage export: another way to back up (a.tar.gzfile)image import: import exported containers and imagesimage download: save registry images to.tar.gzimage local: list and manage your imagescontainer rm: remove a container after committing it
Keep images small: before committing, clean up inside the container (apt-get clean, old logs, caches). For a portable backup, use image export instead.
Commit, export or download?
container commitcreates an image you reuse to create new containers.image exportcreates a compressed file to back up or move to another machine.image downloadsaves a published image to a file for offline use.