Cleaning Up Docker Volumes, Images and Containers (Native/Traditional)

Jenna
Jenna
  • Updated

Author: Jenna Zwick

Date: September 15, 2023

Audience: Everyone

Environmental details: 

Ubuntu 20.04, 22.04, or RHEL with DockerCE

Problem/Summary:

Over time, old docker images, containers, and volumes can become abandoned but stay on the app server's storage. This can accumulate over time and be a problem for system administrators who allocate the minimum storage required to run Jama Connect or for situations where Jama Connect doesn't start and reports low or no free disk space.

Symptoms:

The output of 'docker ps -a' looks cluttered with several "Exited" containers, error messages about low disk space, and high % used on / partition. At worst, it can keep Jama Connect from starting up.

In these situations, you may also have difficulties generating a support bundle.

Solution:

  1. Access your Jama Connect application server using the administrator's login and password.
  2. In the terminal, run ' df -h' and look for disk partitions with 90+% usage. These are the ones I think I should be concerned about.
    (Contact Support if you have trouble parsing the output of this command.)
  3. Run
    docker ps -a
    A clean Jama Connect installation will typically have under 17-25 containers; not all will run when the application is. You probably have some clutter if you have many more or see duplicate container names.

Before performing this procedure, back up your instance and verify the backup's integrity. Only run the following commands while the application is running. 

You only need to run these commands to remove excess containers, images, and volumes. You may need to use sudo or have logged in as 'root.'

Each cleanup command can take up to several minutes to execute entirely if more than 100 objects are present. The process is:

  1. Prune images. This removes images not associated with a container.
    docker image prune
  2. Prune dangling volumes. This removes the storage volume from the server without a parent container.
    docker volume rm $(docker volume ls -qf dangling=true)
  3. Restart the 'tenant manager' container to keep it from being pruned.
    docker ps --format '{{.Names}}' | grep 'tenant' | xargs -r docker restart
  4. Prune dangling containers. This removes containers that have been stopped for over a day.
    docker container prune --filter "until=24h"

  5. Verify functionality. Try to access Jama Connect with your web browser to verify the application is still running.

Cause:

Leftover files from previous updates on the Jama Connect application server.

Prevention:

It is recommended that system admins maintaining a self-hosted installation make it part of their upgrade process. Running these commands after every upgrade and while the upgraded application is up and running will keep old images from piling up on the server. 

 

Feedback: Did this article help you resolve your problems with a slow application server or even get you back online if you were down? Please leave feedback in the comments below!

 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.