Best practices for removing old containers?


(Allen - Watchman Monitoring) #1

Continuing the discussion from How do I update my Docker image to latest?:

We got a notice on one of our servers that disk space was low.

The download_remote_images_to_local setting was disabled because the disk space limit at `download_remote_images_threshold was reached.

When following Sam’s commands, we ended up with 95% of our space used on our boot drive.

Following Sam’s recommendations here, I was told that docker had tried to delete items which were still marked as in-use. Is this normal or OK? Maybe it’s a Docker issue?

# docker rm `docker ps -aq`
Error response from daemon: Conflict, You cannot remove a running container. Stop the container before attempting removal or use -f
FATA[0000] Error: failed to remove one or more containers 
root@discuss:/var/discourse# docker rmi `docker images -aq`
Error response from daemon: Conflict, cannot delete 91f6dfa70a1a because the running container aa1d4d35c8be is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete 1e6d9a1f7326 because the running container aa1d4d35c8be is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete 2a29f41bee3a because the running container aa1d4d35c8be is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete 8ef4bef407a1 because the running container aa1d4d35c8be is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete bc6884534416 because the running container aa1d4d35c8be is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ac3bba3cdcf5 because the running container aa1d4d35c8be is using it, stop it and use -f to force
Deleted: d5cdf7304e3a36b7443ce96a239d249953323b507fb7f0b84d90fe0f31c69170
Deleted: 4b87ea2e8f289b63e722fbe58b75ade579694c3828154c7a77dad9c4b2fe1a47

(Jeff Atwood) #2

What version of Docker? What version of the Discourse container? What version of Discourse? This is our standard Docker install you are describing?


(Sam Saffron) #3

In latest just run

./launcher cleanup

(Allen - Watchman Monitoring) #4

Thanks @sam that worked better:

s:/var/discourse# ./launcher cleanup

The following command will
- Delete all docker images for old containers
- Delete all stopped and orphan containers

Are you sure (Y/n): Y
Starting Cleanup
17418968
17418964
./launcher cleanup cleared up 4 of disk space.

Not sure 4 of what though…

and @codinghorror sorry for not including that useful information… this was all done on the latest docker 1.5 after having just rebuilt the container to get to the latest docker image. The upgrade itself had gone smoothly, but shortly after we were notified that there wasn’t enough space on disk.


(Sam Saffron) #9

Math is bash is HARD :stuck_out_tongue_winking_eye:


(Kane York) #10

Just use dc, the reverse-polish desk calculator!


(Mark Lilly) #11

If i’m on Docker version 1.2.0, build fa7b24f (which i am) and i don’t find the ./launcer cleanup command, what’s my best option?

Thanks,
m

ps, instead i get multiple options, but not ‘cleanup’:

Usage: launcher COMMAND CONFIG [--skip-prereqs]

Commands:
start:      Start/initialize a container
stop:       Stop a running container
etc...

(Kane York) #12

You need to git pull to update your launcher, and update your Docker version as well with apt-get install lxc-docker.