如何在Ubuntu中增加Docker磁盘映像大小 [英] How to increase docker disk image size in Ubuntu

查看:388
本文介绍了如何在Ubuntu中增加Docker磁盘映像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在ubuntu上增加docker映像的大小。当我执行docker info时,我得到以下信息

I am trying to increase the docker image size on ubuntu. When I do docker info I get following info

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.09.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-87-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.67GiB
Name: no1010042033112.corp.adobe.com
ID: PYZE:KYTG:DXED:QI37:43ZM:56BB:TLM6:X2OJ:WDPA:35UP:Z4CU:DSNC
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

如您所见,总内存为总内存:15.67GiB。我找不到在Ubuntu上执行此操作的方法。我尝试了以下方法

As you can see that total memory is Total Memory: 15.67GiB. I couldn't find a way to do it on Ubuntu. I tried following ways

1)sudo dockerd --storage-opt dm.basesize = 100G
2)更改DOCKER_OPTS =-storage-opt dm。在/ etc / default / docker中找到basesize = 50G。

1) sudo dockerd --storage-opt dm.basesize=100G 2) Changing DOCKER_OPTS ="--storage-opt dm.basesize=50G" in /etc/default/docker.

但是这些都没有帮助。在Windows的Docker配置中可以轻松使用此选项。但是如何从ubuntu终端上做到这一点

But none of these helped. This option is easily available in Docker config in Windows. But how to do it from a ubuntu terminal

推荐答案

Docker,在Linux上,具有 overlay2 存储驱动程序,使用主机系统的所有磁盘(和内存)。没有办法使它使用更少的磁盘(不重新分配主系统磁盘),也没有办法提供更多的磁盘(不添加新硬件)。

Docker, on Linux, with the overlay2 storage driver, uses all of the host system's disk (and memory). There's no way to make it use less disk (without repartitioning your main system disk) and no way to give it more (without adding new hardware).

适用于Mac的Docker,适用于Windows的Linux风格的Docker和Docker Machine都可以通过运行最低Linux OS的虚拟机来运行。该VM具有特定的磁盘和内存分配,并且具有UI控件,但这是因为容器在不同的OS上运行并且需要实际的虚拟化层。

Docker for Mac, the Linux-flavored Docker for Windows, and Docker Machine all work by launching virtual machines that run a minimal Linux OS. That VM has a specific disk and memory allocation and there's UI controls for it, but it's because the containers are running on a different OS and need an actual virtualization layer.

在Linux上,Docker还支持多个存储驱动程序。这些需要不同数量的Linux内核支持。早期版本的Docker使用了称为 devicemapper 的方法,该方法通过在(通常是固定大小的文件),然后提供 dm.basesize 选项( dm代表 devicemapper)。当前版本的Linux上的当前版本的Docker使用名为 overlay2 的不同驱动程序只是将图像和容器内容存储在普通目录中。您仍然需要内核支持,但是没有保留或有限的磁盘空间。这就是为什么 docker info 输出中唯一的大小数字是 memory 的原因,这是另一种资源。

On Linux, Docker also supports several storage drivers. These require varying amounts of Linux kernel support. Early versions of Docker used something called devicemapper which worked by allocating space in (most often) a fixed-size file, and then the dm.basesize option you give matters ("dm" is for "devicemapper"). Current versions of Docker on current versions of Linux use a different driver called overlay2 which just stores image and container content in ordinary directories. You still need kernel support for it but there's no reserved or limited disk space. That's also why the only size number in the docker info output is memory, which is a different resource.

这篇关于如何在Ubuntu中增加Docker磁盘映像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆