Skip to main content

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​

Linux
docker volume create ros-data
docker volume ls

Mount into a container​

Use -v volume-name:container-path (the volume is auto-created if missing):

Linux
docker run -d --name ros-node -v ros-data:/root/.ros ros:humble

You can also bind-mount a host directory, useful for hot-reloading code during development:

Linux
docker run -d --name ros-node -v $PWD/src:/workspace/src ros:humble

Clean up volumes​

Remove a specific volume (errors if still in use by a container):

Linux
docker volume rm ros-data

Remove all unused volumes:

Linux
docker volume prune

⚠️ Removing a volume is irreversible — back up data first. See Network Commands for how volumes differ from networks.

Join Us