增加容器大小操作系统(ubuntu 16.04)

增加容器大小操作系统(ubuntu 16.04)

我刚刚下载了 ubuntu

docker pull ubuntu:16.04

然后我想在其中安装 mysql 和 nginx,但大小有限

docker run -d -t --name temporary ubuntu:16.04
winpty docker exec -it temporary bash
df -h

我得到了

root@90215dee6bc7:/# df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay         991M  280M  711M  29% /
tmpfs           991M     0  991M   0% /dev
tmpfs           991M     0  991M   0% /sys/fs/cgroup
tmpfs           991M  280M  711M  29% /etc/hosts
shm              64M     0   64M   0% /dev/shm
tmpfs           991M     0  991M   0% /sys/firmware

如何增加该尺寸?

我想要 20GB 大小

我的docker信息:

Containers: 1
 Running: 1
 Paused: 0
 Stopped: 0
Images: 2
Server Version: 17.03.1-ce-rc1
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 macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 4ab9917febca54791c5f071a9d1f404867857fcc
runc version: 54296cf40ad8143b62dbcaa1d90e520a2136ddfe
init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.13-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934 GiB
Name: moby
ID: 6HQT:YHNE:ITRU:5T2E:IVVR:7XX6:GO67:7RXP:MQB3:AZ35:IZLK:QQ6B
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 23
 Goroutines: 27
 System Time: 2019-07-30T03:05:52.0912243Z
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

答案1

如果您只想创建一个容器,那么:

docker create -it --storage-opt size=20G ubuntu:16.04 /bin/bash



如果您想增加存储驱动程序的默认基本大小,那么:

dockerd --storage-opt dm.basesize=20G
  • 确保重新启动docker守护进程 systemctl restart docker,然后您就可以执行之前的拉取和运行。

相关内容