Docker 构建导致 "no space left on device" 在 Windows 10

Docker build leads to "no space left on device" on Windows 10

当我想在 Windows 上构建我的图像时,我遇到了一个奇怪的问题。我没有使用 Docker 做任何其他事情,所以安装可以被认为是新鲜的。根本没有卷,也没有图像。

当我尝试从我的 Docker 文件构建我的应用程序时,它以这个错误结束

docker build ./
Sending build context to Docker daemon   1.4 GB
Error response from daemon: Error processing tar file(exit status 1): write /.bowerrc: no space left on device

我听说你可以增加 docker 的基数,但我还没有找到 Windows 的解决方案(为什么这甚至在默认情况下受到限制?)

docker info 打印了一些东西,但它根本没有显示 "Storage Driver" 下的任何基本大小

$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.13.1
Storage Driver: overlay2
 Backing Filesystem: tmpfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1
runc version: 9df8b306d01f59d3a8029be411de015b7304dd8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.8-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934 GiB
Name: moby
ID: GUXQ:KPKS:PHBV:BMEF:QHHM:B2YG:MWPB:2W5H:Z3GX:27YS:QBT6:O4RV
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 13
 Goroutines: 21
 System Time: 2017-02-19T20:15:57.8764828Z
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

根据互联网上的一些帖子,这曾经是或者是继续 Linux 的方式,但它在 Windows

上不起作用

docker daemon --storage-opt dm.basesize=20G

我的 docker 安装有什么问题,如何增加基本大小?

我已经重新安装 Docker 现在它似乎可以工作了

我在 Windows 上遇到了同样的问题。这两个设置之一应该可以解决这个问题:

  • 增加 Docker 使用的内存。如果是2GB,加多
  • 增加"Disk image max size" - 初始为 60,将其移动到 80 GB

这应该足够了,但取决于您正在构建的内容的复杂性。在某些情况下,需要增加 Swap。 Docker 的初始 Swap 是 1024 MB

谢谢

我重置为出厂默认设置,然后select:删除所有图像。 在高级选项卡:增加'Disk image max size'(我修改为80 GB) 然后再次构建 docker

这不会是 2017 年 OP 的根本问题,但如果您在使用 Windows 10 1903 时遇到此问题,那么您可能 运行 进入 Docker 对于 Windows issue #4100 ("Windows 1903 fails when storage-opt used").

2020 年 1 月 6 日,commit was pushed to the docker-ce GitHub repository 从评论(下方)看来似乎对 Windows 中的潜在错误实施了解决方法。

  • microsoft/hcsshim#718 wclayer: Work around Windows bug when expanding sandbox size
    • fixes microsoft/hcsshim#708 Windows Host Compute Service bug breaks docker (and other) sandboxes bigger than 20G on Windows 1903
    • fixes microsoft/hcsshim#624The hcsshim on Windows 10 1903 always fails to build Docker image
    • fixes/addresses docker/for-win#3884 An error occurred while attempting to build Docker image (especially this comment and the next comments after: docker/for-win#3884 (comment))
    • fixes/addresses docker/for-win#4100 Windows 1903 fails when storage-opt used
    • fixes moby/moby#36831 hcsshim::PrepareLayer failed in Win32: The parameter is incorrect (moby/moby#36831 (comment))
    • fixes Stannieman/audacity-with-asio-builder#5 Docker won't build container
    • fixes MicrosoftDocs/visualstudio-docs#3523 Error when running build with storage-opts set
    • fixes moby/moby#39524 Docker build windows 19.03 --storage-opt size>20G

不幸的是,Docker 的新版本还没有包含这个提交,所以我们这些在 1903 上遇到这个错误的人暂时被卡住了。

假设您在开发环境中执行此操作,只需 运行:

docker system prune -a -f

注意:不要在生产环境中运行这样做