How to correctly remove volume directories from Docker
Posted on
After playing with CoreOS and fleet on Vultr for some weeks, there were too many directories in /var/lib/docker/vfs/dir/ and /var/lib/docker/volumes. I had no choice but to remove these directories manualy. But when it comes to production environment, of course it is not acceptable. Thankfully, I found a blog post of Docker In-depth Volumes. I learned how to correctly remove volume directories with docker rm -v commands.
After playing with CoreOS and fleet on Vultr for some weeks, there were too many directories in /var/lib/docker/vfs/dir/ and /var/lib/docker/volumes. I had no choice but to remove these directories manualy. But when it comes to production environment, of course it is not acceptable. Thankfully, I found a blog post of Docker In-depth: Volumes. I learned how to correctly remove volume directories with docker rm -v commands.
-f, --force=false Force the removal of a running container (uses SIGKILL) -l, --link=false Remove the specified link and not the underlying container -v, --volumes=false Remove the volumes associated with the container
Updating fleet unit files
As usual Docker containers on CoreOS controlled by fleetctl. I create unit files on local machine and submit and start services.
A remained directory which used by BitTorrent Sync data volume container might be cause of Error while adding folder /data: Selected folder is already added to BitTorrent Sync. error.
ExecStartPre directives
I revised my unit files using docker rm commands on ExecStartPre directive. If using --volumes-from flag and binding two containers, both of docker rm commands need -v flag following instrucions.