Freeing Up Monitor Disk Space
journalctl
-
Run the following command to check disk usage:
$ journalctl --disk-usage -
Reduce journald's disk usage by running the following command:
$ journalctl --vacuum-size=<integer>
docker unused images
-
Check for multiple images by running the following command:
$ docker image ls -a --digestsIf there are multiple images, check for the existence of unused images by comparing the outputs of the following two commands:
$ docker ps -a --no-trunc --format 'table {{.Image}}\t{{.ID}}\t{{.Status}}\t{{.Names}}'and
$ docker image ls -a --digests -
The digest of a docker image is shown after the
@in theIMAGEof the output of thedocker pscommand. -
Determine if any of the images that are not being used by running containers are still needed. Remember that there may exist transient containers that are not currently running but are still in use.
-
If you determine that there exist images not being used by running containers and that those images are no longer needed, run the following command to check for dangling images:
$ ls -lah /var/lib/docker/overlay2/Any currently-running image in overlay2 has two directory entries that have nearly-identical names. The second name has
- initappended. Any directory that is listed once and does not end in- initis unused. -
Alternatively, you can check each running container's name, image, and overlay2 paths by running the following command:
$ docker inspect <container id from docker ps> | jq -r '.[] | .Name,.Image,.GraphDriver'Ensure that any image not in current use is indeed not transient and is in fact no longer in use.
-
After you have confirmed that there exist overlay2 directories that are no longer needed, remove them and reclaim their disk space by using
docker image prune. Consult the 'docker image prune' documentation before runningdocker image prune -a.
Docker Logs
-
By default, docker logs do not rotate. They grow throughout the uptime of the container. Check
/etc/dockerto confirm the presence of thedaemon.conffile. If it is present, cat it to determine whether it contains "log-opts". "log-opts" control docker-container log rotation. -
Check the size of the container logs by running the following command:
$ ls -lah /var/lib/docker/containers/*/*.logRemember that logs are lost on container exit.
-
If large logs exist, check to make sure that it is safe to restart the container with the large log file or large log files. Note that the
CONTAINER IDreturned bydocker psis embedded in the path to the log file, for example/var/lib/docker/containers/<CONTAINER ID>/<CONTAINER ID>-json.log. -
If it is safe to restart the container, determine whether you should preserve the log file. Preserve the file if you need to preserve it, and then run the following commands to restart the docker container:
In one terminal, monitor the following command:
$ watch ceph -SIn another terminal, restart the container by running a command of the following form:
$ ceph orch daemon restart <ceph orch ps name>
General Docker Tips
To map running containers to the overlay directory that they use, run the following script:
if [ -f rpt ]; then rm rpt; fi; echo "CONTAINER_ID NAME
OVERLAY_DIR" >> rpt; for d in $(docker ps | grep -v
CONTAINER | awk '{print $1}'); do name=$(docker inspect $d |
jq -r '.[] | .Name'); overlay=$(docker inspect $d | jq -r '.
[] | .GraphDriver.Data.MergedDir'); echo $d $name $overlay
>> rpt; done; cat rpt | sed 's|/ceph|ceph|' | sed
's|/merged||' | column -t
To get a brief overview of docker space, run the following command:
# docker system df