我想删除Docker守护程序;因为这会占用我的PC上更多的空间
我确实插入了安装php:5.3-apache
我使用了docker build -t my-php-app这个命令。
我收到此错误
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
所以我想删除该守护进程,因为它占用了我PC上的很大空间;我确实尝试了3次来安装它,每次都出现相同的错误,所以我现在有超过21GB的空间要清理。
docker镜像给我:
orsolin/docker-php-5.3-apache latest d8e72369c6e9 2 years ago 533MB
但是我计算机上的空间已从30GB减少到8GB
我看不到7GB的大小
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
答案 0 :(得分:3)
Docker内部运行在客户端/服务器架构上。特别是,当您运行docker build
时,它将创建您指定目录的tar文件,将该tar文件通过套接字发送到Docker守护程序,然后在其中解压缩。 (即使在完全本地的系统上也是如此。)
如果出现问题,可以在/var/lib/docker/tmp
中备份该内容。通常,您根本不需要浏览/var/lib/docker
,但清理该目录应该是安全的。考虑在执行该操作时停止该守护程序。停止守护程序,删除所有/var/lib/docker
并重新启动守护程序也将有所帮助(您将需要重新{docker build
和/或docker pull
映像并重新运行容器,这将在尚未备份的命名卷中丢失任何内容。
7.039 GB的构建上下文非常大。除了类似这样的问题,它只会导致docker build
步骤非常缓慢;如果所有这些内容都COPY
编辑进入图像,则尝试docker push
构建的图像时,您可能会遇到类似的问题。您可以尝试清理掉日志文件或堆转储之类的东西;将.git
目录或本地供应商树之类的内容添加到.dockerignore
文件中也可以帮助减小上下文的大小。
答案 1 :(得分:1)
您不想删除该守护程序,该守护程序实际上是您的主机上运行的能够运行docker命令的软件。
如果要删除现有的映像,卷,容器,网络,构建缓存,可以深入该命令
docker system prune
请注意,它会删除很多您可能仍会使用的东西。
如果要确定占用主机空间的原因,则在进行任何清理之前,还可以运行
$ 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%)
有关它的文档: https://docs.docker.com/engine/reference/commandline/system_df/
这可能会回收主机上的大量空间,甚至会给您它回收的空间量的总和:
$ 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
最根本的形式是:
$ 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
文档可在此处找到: https://docs.docker.com/engine/reference/commandline/system_prune/