Volume Commands
Containers are ephemeral — data written inside them is lost on restart. A volume is Docker-managed persistent storage, independent of the container lifecycle. Even if the container is removed, the volume's data remains.
Create and list
docker volume create ros-datadocker volume lsMount into a container
Use -v volume-name:container-path (the volume is auto-created if missing):
docker run -d --name ros-node -v ros-data:/root/.ros ros:humbleYou can also bind-mount a host directory, useful for hot-reloading code during development:
docker run -d --name ros-node -v $PWD/src:/workspace/src ros:humbleClean up volumes
Remove a specific volume (errors if still in use by a container):
docker volume rm ros-dataRemove all unused volumes:
docker volume prune⚠️ Removing a volume is irreversible — back up data first. See Network Commands for how volumes differ from networks.