skip to Main Content

I want to delete a Docker daemon; because it take more space on my pc
I did insert a code to install php:5.3-apache

I used this command docker build -t my-php-app .

I get this error

Sending build context to Docker daemon  7.039GB
Error response from daemon: unexpected error reading Dockerfile: read /var/lib/docker/tmp/docker-builder079515785/dockerfile: is a directory

so I want to delete that daemon because It take big space on my pc; I did tried 3 times to install it and every-time I get the same error so I have now more than 21GB that I want to clean.

docker images give me :

orsolin/docker-php-5.3-apache   latest              d8e72369c6e9        2 years ago         533MB

but space on my computer has been decreased from 30GB to 8GB

I don’t see anything with 7GB of size

REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
abv_web                         latest              2194cdd678e3        45 hours ago        5.09GB
<none>                          <none>              58b330f4aa2f        46 hours ago        623MB
<none>                          <none>              c4b5c889111d        46 hours ago        623MB
<none>                          <none>              cfe4161b5af4        46 hours ago        623MB
<none>                          <none>              f37f2a95529a        46 hours ago        623MB
httpd                           latest              19459a872194        4 days ago          154MB
phpmyadmin/phpmyadmin           latest              d8d2c1fd1eb9        9 days ago          458MB
phpmyadmin/phpmyadmin           edge                4b557b055a8c        9 days ago          458MB
pweb_joomla                     latest              22c6d70d575e        10 days ago         1.01GB
fweb_joomla                     latest              0e36548560af        11 days ago         2.47GB
joomla                          apache              73acf8852f1b        13 days ago         461MB
mysql                           5.6                 732765f8c7d2        4 weeks ago         257MB
joomla                          3.9.5-apache        398227376f4a        4 months ago        415MB
alterway/php                    5.3-apache          87058120bc90        8 months ago        623MB
orsolin/docker-php-5.3-apache   latest              d8e72369c6e9        2 years ago         533MB
airinuit_mysql                  latest              fa73519d1891        2 years ago         304MB
vsamov/mysql-5.1.73             latest              fa73519d1891        2 years ago         304MB

2

Answers


  1. You don’t want to delete the daemon, the daemon is actually the piece of software running on your host machine that able you to run docker commands.

    If you want to remove existing images, volumes, containers, networks, build caches, you can dig into the command

    docker system prune
    

    Be careful with it, it will delete a lot things that you possibly still might use.

    If you want to identify what does takes space in your host, prior to rennung any clean up, you can also run

    $ docker system df
    
    TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
    Images              5                   2                   16.43 MB            11.63 MB (70%)
    Containers          2                   0                   212 B               212 B (100%)
    Local Volumes       2                   1                   36 B                0 B (0%)
    

    Documentation about it: https://docs.docker.com/engine/reference/commandline/system_df/

    That could reclaim lots of space on your host machine, and will even give you a sum up of the amount of space it reclaims:

    $ docker system prune
    
    WARNING! This will remove:
            - all stopped containers
            - all networks not used by at least one container
            - all dangling images
            - all build cache
    Are you sure you want to continue? [y/N] y
    
    Deleted Containers:
    f44f9b81948b3919590d5f79a680d8378f1139b41952e219830a33027c80c867
    792776e68ac9d75bce4092bc1b5cc17b779bc926ab04f4185aec9bf1c0d4641f
    
    Deleted Networks:
    network1
    network2
    
    Deleted Images:
    untagged: hello-world@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f
    deleted: sha256:1815c82652c03bfd8644afda26fb184f2ed891d921b20a0703b46768f9755c57
    deleted: sha256:45761469c965421a92a69cc50e92c01e0cfa94fe026cdd1233445ea00e96289a
    
    Total reclaimed space: 1.84kB
    

    The most radical form of it being:

    $ docker system prune --all --volumes
    
    WARNING! This will remove:
            - all stopped containers
            - all networks not used by at least one container
            - all volumes not used by at least one container
            - all images without at least one container associated to them
            - all build cache
    Are you sure you want to continue? [y/N] y
    
    Deleted Containers:
    0998aa37185a1a7036b0e12cf1ac1b6442dcfa30a5c9650a42ed5010046f195b
    73958bfb884fa81fa4cc6baf61055667e940ea2357b4036acbbe25a60f442a4d
    
    Deleted Networks:
    my-network-a
    my-network-b
    
    Deleted Volumes:
    named-vol
    
    Deleted Images:
    untagged: my-curl:latest
    deleted: sha256:7d88582121f2a29031d92017754d62a0d1a215c97e8f0106c586546e7404447d
    deleted: sha256:dd14a93d83593d4024152f85d7c63f76aaa4e73e228377ba1d130ef5149f4d8b
    untagged: alpine:3.3
    deleted: sha256:695f3d04125db3266d4ab7bbb3c6b23aa4293923e762aa2562c54f49a28f009f
    untagged: alpine:latest
    deleted: sha256:ee4603260daafe1a8c2f3b78fd760922918ab2441cbb2853ed5c439e59c52f96
    deleted: sha256:9007f5987db353ec398a223bc5a135c5a9601798ba20a1abba537ea2f8ac765f
    deleted: sha256:71fa90c8f04769c9721459d5aa0936db640b92c8c91c9b589b54abd412d120ab
    deleted: sha256:bb1c3357b3c30ece26e6604aea7d2ec0ace4166ff34c3616701279c22444c0f3
    untagged: my-jq:latest
    deleted: sha256:6e66d724542af9bc4c4abf4a909791d7260b6d0110d8e220708b09e4ee1322e1
    deleted: sha256:07b3fa89d4b17009eb3988dfc592c7d30ab3ba52d2007832dffcf6d40e3eda7f
    deleted: sha256:3a88a5c81eb5c283e72db2dbc6d65cbfd8e80b6c89bb6e714cfaaa0eed99c548
    
    Total reclaimed space: 13.5 MB
    

    Documentation could be found here: https://docs.docker.com/engine/reference/commandline/system_prune/

    Login or Signup to reply.
  2. Docker internally runs on a client/server architecture. In particular, when you run docker build, it creates a tar file of the directory you specify, sends that tar file across a socket to the Docker daemon, and unpacks it there. (True even on a totally local system.)

    If something goes wrong, that content can back up in /var/lib/docker/tmp. Usually you shouldn’t be poking around in /var/lib/docker at all, but cleaning out this directory should be safe. Consider stopping the daemon while you do it. Stopping the daemon, deleting all of /var/lib/docker, and restarting the daemon should also help (you will need to re-docker build and/or docker pull images and re-run containers, and this will lose anything in named volumes you haven’t backed up).

    The 7.039 GB build context is very large. In addition to problems like this it will just result in the docker build step being very slow; if all of that content gets COPYEd into the image you will probably hit similar problems trying to docker push the built image. You can try cleaning up things like log files or heap dumps if those are left lying around; adding things like your .git directory or a local vendor tree to a .dockerignore file can also help reduce the size of the context.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search