科利马:增加Docker镜像大小限制

8
我正在通过Colima运行Docker,我的镜像大小总共达到了约10GB。为了继续使用,我需要增加这个大小。
在Colima中是否有定义这个大小的方法?

2
您没有提供足够的细节。为什么需要增加大小?VM是否已经用完了磁盘空间?您可以使用 docker system prune 来修剪 Docker 镜像,或者删除并重新创建具有更大磁盘大小的 Colima VM。 - abiosoft
我需要它,因为我有几个正在运行的容器,使用大小至少为5GB的镜像。一个例子是kafka ;) - Deniss M.
3个回答

18

Colima - 自定义虚拟机

Colima 创建的默认虚拟机具有 2 个 CPU、2GiB 内存和 60GiB 存储空间。

可以通过向 colima start 传递其他标志(例如 --cpu、--memory、--disk、--runtime)或使用 colima start --edit 编辑配置文件来自定义虚拟机。

注意:从 v0.5.3 开始,虚拟机创建后无法更改磁盘大小。 现在可以增加磁盘大小。

自定义示例

创建具有 1 个 CPU、2GiB 内存和 10GiB 存储空间的虚拟机。

colima start --cpu 1 --memory 2 --disk 10

将现有的虚拟机修改为4个CPU和8GiB内存。

colima stop
colima start --cpu 4 --memory 8

将存储空间调整为100 GB。

colima stop
colima start --disk 100

参考资料

https://dev59.com/U3oPtIcB2Jgan1znyGXl#74402260@Carlos Cavero 提供

https://github.com/abiosoft/colima#customizing-the-vm

https://github.com/abiosoft/colima/blob/main/docs/FAQ.md


1
这已经不正确了。从Colima v0.5.3开始,磁盘大小可以增加。https://github.com/abiosoft/colima#customizing-the-vm - Tom Davies

13

我曾遇到同样的问题,可以通过自定义Colima VMs来调整CPU、内存(GB)和磁盘(GiB)大小:

colima start --cpu 4 --memory 4 --disk 100

但是这很奇怪,因为文档中说明:

由 Colima 创建的默认虚拟机具有 2 个 CPU、2GiB 的内存和 60GiB 存储空间


2
简直不敢相信我一直在Dockerfile中寻找错误,结果发现是Colima内存太低了。 - Emir Husic

3
运行 `colima template` 并自定义默认的机器模板,这样下次运行 `colima start` 时就可以直接进入它。
# ============================================================================================ #
# To abort, delete the contents of this file including the comments and save as an empty file
# ============================================================================================ #

# New instances will be created with the following configurations.

# Number of CPUs to be allocated to the virtual machine.
# Default: 2
cpu: 4

# Size of the disk in GiB to be allocated to the virtual machine.
# NOTE: changing this has no effect after the virtual machine has been created.
# Default: 60
disk: 120

# Size of the memory in GiB to be allocated to the virtual machine.
# Default: 2
memory: 12

# Architecture of the virtual machine (x86_64, aarch64, host).
# Default: host
arch: host

# Container runtime to be used (docker, containerd).
# Default: docker
runtime: docker

# Kubernetes configuration for the virtual machine.
kubernetes:
  # Enable kubernetes.
  # Default: false
  enabled: false

  # Kubernetes version to use.
  # This needs to exactly match a k3s version https://github.com/k3s-io/k3s/releases
  # Default: latest stable release
  version: v1.24.3+k3s1

  # Additional args to pass to k3s https://docs.k3s.io/cli/server
  # Default: traefik is disabled
  k3sArgs:
    - --disable=traefik

# Auto-activate on the Host for client access.
# Setting to true does the following on startup
#  - sets as active Docker context (for Docker runtime).
#  - sets as active Kubernetes context (if Kubernetes is enabled).
# Default: true
autoActivate: true

# Network configurations for the virtual machine.
network:
  # Assign reachable IP address to the virtual machine.
  # NOTE: this is currently macOS only and ignored on Linux.
  # Default: false
  address: false

  # Custom DNS resolvers for the virtual machine.
  #
  # EXAMPLE
  # dns: [8.8.8.8, 1.1.1.1]
  #
  # Default: []
  dns: []

  # DNS hostnames to resolve to custom targets using the internal resolver.
  # This setting has no effect if a custom DNS resolver list is supplied above.
  # It does not configure the /etc/hosts files of any machine or container.
  # The value can be an IP address or another host.
  #
  # EXAMPLE
  # dnsHosts:
  #   example.com: 1.2.3.4
  dnsHosts:
    host.docker.internal: host.lima.internal

  # Network driver to use (slirp, gvproxy), (requires vmType `qemu`)
  #   - slirp is the default user mode networking provided by Qemu
  #   - gvproxy is an alternative to VPNKit based on gVisor https://github.com/containers/gvisor-tap-vsock
  # Default: gvproxy
  driver: gvproxy

# ===================================================================== #
# ADVANCED CONFIGURATION
# ===================================================================== #

# Forward the host's SSH agent to the virtual machine.


完成后,您可能需要执行colima delete以获取更新的虚拟机资源。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接