Docker in workspaces and volumes
Hello,
I'm running container with Sysbox in Kubernetes based workspaces. I have persisted with Kubernetes PV the workspace
/home/coder
and /var/lib/docker
directory. Developers run container inside their workspace with --rm
option (docker run --rm
) so while restarting the coder workspace, the nested developers container should be deleted. This working well except for anonymous volumes that are created with the developers container. While i'm restarting the workspace, and checking the /var/lib/docker/volumes
the anonymous still there. These lead to full fill the Kubernetes PV. It's look like a problem of gracefull shutdown of the workspace that running docker container.
Is anyone as encounter the same problem ?10 Replies
<#1275743565162741806>
Category
Bug report
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
yes, this makes sense as docker doesn't delete the volumes by default
you should add a
docker volume prune -f
line to the coder_agent
's shutdown_script
if you want dangling volumes goneThanks, Good idea for the
shutdown_script
. But docker is supposed to deleted anonymous volume when --rm
option is specified as mentionned here in the doc: Anonymous volumes are given a random name that's guaranteed to be unique within a given Docker host. Just like named volumes, anonymous volumes persist even if you remove the container that uses them, except if you use the --rm flag when creating the container, in which case the anonymous volume is destroyed
(https://docs.docker.com/engine/storage/#volumes).do the volumes get deleted if you gracefully shutdown the container that was started via
docker run
?yes, here is an example while stopping the container by myself:
And here is with restarting the workspace:
hey, could you try adding something like
docker stop $(docker ps -a -q)
(to stop all containers) in your shutdown_script
to see if you get the intended behavior?It's working well, I have add
xagrs
to manage case when there si no container. Thanksalright
could you open an issue on GitHub to ask if there isn't something Coder should be doing to gracefully stop Docker?
GitHub
Gracefully stop Docker · Issue #14465 · coder/coder
Problem An issue occurred while stopping/starting or restarting workspaces that run docker container. It's look like, docker container aren't gracefully shutdown because anonymous volumes a...
thanks a lot!