Skip to content
This repository has been archived by the owner on Mar 27, 2018. It is now read-only.

Cleanup of images #21

Open
rosskevin opened this issue Oct 27, 2015 · 3 comments
Open

Cleanup of images #21

rosskevin opened this issue Oct 27, 2015 · 3 comments

Comments

@rosskevin
Copy link
Member

It seems like while we do appear to be cleaning up volumes, we are still accumulating images.

Here's a sample of docker images:

$ docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
51paralleltests7_web   latest              d71d2445bdfb        13 minutes ago      847.6 MB
51paralleltests6_web   latest              95a1b6defafd        19 minutes ago      847.6 MB
51paralleltests5_web   latest              1255214a7fda        About an hour ago   847.6 MB
51paralleltests4_web   latest              ee4a0f5cfb9f        About an hour ago   847.6 MB
51paralleltests3_web   latest              bca2d62b4ba6        2 hours ago         845 MB
1paralleltests72_web   latest              b3ebff13b92b        11 days ago         846.9 MB
1paralleltests71_web   latest              7d75f8a8ad37        11 days ago         846.9 MB
1paralleltests70_web   latest              4df55b6f839c        12 days ago         846.8 MB
1paralleltests69_web   latest              2b9018ccb4f0        12 days ago         846.8 MB
1paralleltests68_web   latest              21ed8847ce71        12 days ago         846.7 MB
1paralleltests67_web   latest              b1150e3df26a        12 days ago         846.7 MB
1paralleltests66_web   latest              abadec4bf961        12 days ago         846.7 MB
1paralleltests65_web   latest              973873f0ca23        12 days ago         846.6 MB
1paralleltests64_web   latest              2e08b5c52e2f        12 days ago         846.6 MB
1paralleltests63_web   latest              e791aa884c94        13 days ago         846.6 MB
1paralleltests62_web   latest              d4e11c7a138a        13 days ago         846.5 MB
1paralleltests61_web   latest              7ccf5ced4084        13 days ago         844.4 MB
1paralleltests59_web   latest              66b5a2de8bcc        13 days ago         848.3 MB
whilp/ssh-agent        latest              a7aad9135c9c        2 weeks ago         8.808 MB
busybox                latest              d7057cb02084        5 weeks ago         1.096 MB
elasticsearch          1.7                 d3aa5ff744e2        5 weeks ago         522 MB
mysql                  5.7                 0e269f9884d9        6 weeks ago         321.2 MB
atlashealth/ruby       2.2.2               a2bb6f84ee61        11 weeks ago        387.6 MB
mysql                  5.7.6               8f71d44defe9        7 months ago        360.9 MB

A couple of potential solutions:

  1. grab the web container image and delete on cleanup
  2. list the containers to cleanup, and only get those that are hours or days old

I'm not sure if there are better solutions. Here's a quick removal of days old web images:

docker rmi $(docker images | grep _web | grep days | grep -o -E " [0-9,a-f]{12} ")

But, when run, it says:

$ docker rmi $(docker images | grep _web | grep days | grep -o -E " [0-9,a-f]{12} ")
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error response from daemon: Conflict, cannot delete ab03de31bf9d because the running container 3a1a3285cfd2 is using it, stop it and use -f to force
Error: failed to remove images: [b3ebff13b92b 7d75f8a8ad37 4df55b6f839c 2b9018ccb4f0 21ed8847ce71 b1150e3df26a abadec4bf961 973873f0ca23 2e08b5c52e2f e791aa884c94 d4e11c7a138a 7ccf5ced4084 66b5a2de8bcc]

Running a docker ps -a, it appears that these old images are a basis for latest builds:

$ docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                               NAMES
3a1a3285cfd2        51paralleltests7_web        "bash -c ' echo 'Bund"   15 minutes ago      Up 15 minutes       0.0.0.0:32782->3000/tcp             51paralleltests7_web_1
1b2d7daec6d3        library/elasticsearch:1.7   "/docker-entrypoint.s"   15 minutes ago      Up 15 minutes       9300/tcp, 0.0.0.0:32781->9200/tcp   51paralleltests7_elasticsearch_1
b39dab6720e7        library/mysql:5.7           "/entrypoint.sh mysql"   15 minutes ago      Up 15 minutes       0.0.0.0:32780->3306/tcp             51paralleltests7_db_1
99d0805cc76c        whilp/ssh-agent:latest      "/run.sh ssh-agent"      15 minutes ago      Up 15 minutes                                           51paralleltests7_ssh_agent
944414e26d18        busybox                     "sh"                     3 weeks ago         Created                                                 gemset-2.2.2

A follow up check on images shows that the images that were shown as failed to remove are now gone:

$ docker images | grep _web 
51paralleltests7_web   latest              d71d2445bdfb        19 minutes ago      847.6 MB
51paralleltests6_web   latest              95a1b6defafd        24 minutes ago      847.6 MB
51paralleltests5_web   latest              1255214a7fda        About an hour ago   847.6 MB
51paralleltests4_web   latest              ee4a0f5cfb9f        About an hour ago   847.6 MB
51paralleltests3_web   latest              bca2d62b4ba6        2 hours ago         845 MB

So I'm a bit confused as to whether or not we need these old images, and as to whether or not they are actually (not virtually) using up much space.

@rosskevin
Copy link
Member Author

Related #28

@rosskevin
Copy link
Member Author

I'm going to try running docker rmi $(docker images | grep _web | grep days | grep -o -E ' [0-9,a-f]{12} ') as part of my before_command

@rosskevin
Copy link
Member Author

We ultimately want to integrate

docker system prune when it is released. See moby/moby#26108

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant