Fixing Dumb Docker Volume Names
I frequently use Portainer and its Stacks feature (which is really just Docker Compose in a fancy hat...) to spin up all manner of random junk. It is probably the laziest way to get from nothing, to a full working service with a web GUI. Here's a list of cool stuff you can run at home, most of which will run via docker. I'll have more to come on this in the future.
While working with Docker volumes I occasionally run into the issue (as you likely have, since you are reading this...) of the directory names not corresponding to the actual names of the volumes.
Above is a snippet of the Compose file for my Nginx Proxy Manager Instance.
As you can see, the volumes are named nginx_data and nginx_letsencrypt.
So why are they instead named this pile of crap? The reason is simple.
Without the external: true flag, docker will assume you haven't already created the volumes, As a result it will create the volumes and name them the way it wants
But I want them named correctly!
Well, it's not as simple as just adding the external flags. You could end up deleting your existing data, or not being able to see the volumes within portainer. We have a few steps to get there first.
Now we need to hop into the command line, and remove the folders portainer just created. All the docker volumes are in /var/lib/docker/volumes
Now the volumes will be named correctly, the folders will be named correctly, and the volumes will actually show up within the volumes section in portainer. Yeehaw.