Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename Docker Volume on Docker Desktop

Tags:

docker

Is it possible to rename a docker volume? I want to change the volume names of the existing container. I see that config.json and hostconfig.json has the volume details in it.

docker run -di -p 8083:443 -v app_main_db_test_1:/var/lib/pgsql/data  -v app_main_conf_test_1:/var/www/ ubuntu

I want to change app_main_db_test_1 to app_main_db and app_main_conf_test_1 to app_main_conf

like image 840
user630702 Avatar asked Nov 05 '25 02:11

user630702


1 Answers

As far as I know, there are no ways of renaming docker volume so far. There is an open GitHub issue, which indicates there is no solution to the topic yet.

But there are a few useful ways to do so. Since you are saying you use Docker Desktop, you could check this comment:

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>

Which should do exactly what you are planning to do.

like image 84
matic1123 Avatar answered Nov 08 '25 01:11

matic1123