![]() ![]() Are you sure you want to continue? y Deleted Containers: 5e7f8e5097ace9ef5518ebf0c6fc2062ff024efb495f11ccc89df21ec9b4dcc2 Total reclaimed space: 104.9MBįrom the output, we can see there is no more space used by containers and, as the image is not used anymore (no container is running), the space it uses on the host filesystem can be reclaimed: $ docker system df TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 1 0 126M 126M (100%) Containers 0 0 0B 0B Local Volumes 0 0 0B 0B Build Cache 0 0 0B 0B ![]() The following commands allow us to delete all stopped containers at once and to reclaim the disk space they’re using: $ docker container prune WARNING! This will remove all stopped containers. How can this space be reclaimed? By deleting the container, which will delete the associate read-write container’s layer. Let’s take a look: # Stopping the (100%) Local Volumes 0 0 0B 0B Build Cache 0 0 0B 0B If we stop the container, the disk space used by the container becomes reclaimable. Without going too deep into the details, this file was created in the container’s read-write layer which is managed by the overlay2 driver. Where is this file located on the host? Let’s take a look: $ find /var/lib/docker -type f -name test.img /var/lib/docker/overlay2/83f177.630078/merged/test.img /var/lib/docker/overlay2/83f177.630078/diff/test.img $ docker system df TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 1 1 126M 0B (0%) Containers 1 1 104.9MB 0B (0%) Local Volumes 0 0 0B 0B Build Cache 0 0 0B 0B ![]() If we check the output of the df command again, we can now see the container now takes up some additional disk space. ![]() This file is created in the read-write layer associated with this container. For this purpose, we use the handy dd command from within the bs=1024 count=0 seek=$ As the size of the container (2B) is negligible and thus not easy to track on the filesystem, let’s create an empty 100MB file in the container’s filesystem. There is no reclaimable space yet as the container is running and the image is currently in use. $ docker system df TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 1 1 126M 0B (0%) Containers 1 1 2B 0B (0%) Local Volumes 0 0 0B 0B Build Cache 0 0 0B 0B one container - the www container run from the NGINX image.This is the NGINX :1.16 one pulled when we launched the container. Running the df command again, we can now see: $ docker system df TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 0 0 0B 0B Containers 0 0 0B 0B Local Volumes 0 0 0B 0B Build Cache 0 0 0B 0Bįirst, we start a NGINX container: $ docker container run -name www -d -p 8000:80 nginx:1.16 Let’s imagine we have a brand new system where Docker has just been installed. If the container persists data in its own filesystem, those will be stored under /var/lib/docker/overlay2 on the host machine. #Trim enabler volume not writable or low on space driver#a folder within /var/lib/docker/overlay2 which contains the container’s read-write layer (overlay2 being the preferred storage driver on most Linux distributions).In this context, generating too many logs might impact the filesystem of the host machine. If the container uses the default logging driver, all its logs will be persisted in a JSON file within this folder. the /var/lib/docker/containers/ID folder (ID being the container’s unique identifier).Each time a container is created, several folders and files are created under /var/lib/docker on the host machine. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |