Rename a Docker volume

Renames a Docker volume by creating a new volume, copying all of its content to from the old to the new volume and then deletes the old volume.

Authored by: Hyruu
Brought to you by Warp, a free terminal reimagined to work like a modern app.
old_volume
new_volume

Command
Copy
docker volume create --name new_volume && docker run --rm -it -v old_volume:/from -v new_volume:/to alpine ash -c 'cd /from ; cp -av . /to' && docker volume rm old_volume
Tags