docker修改默认的存储路径/var/lib/docker

发布时间:2021-05-19 18:20:30 阅读:1488次

因为是在虚拟机中安装了centos只分配了10G的空间

当我安装了docker后

安装服务器如jumpserve,gitlab,jenkins后要不了多久占用了太多的空间

当然可以扩容但是有点麻烦

有没有办法修改docker的存储空间

我们可以通过docker info查看默认的存储空间

Client:
 Debug Mode: false

Server:
 Containers: 4
  Running: 4
  Paused: 0
  Stopped: 0
 Images: 6
 Server Version: 19.03.15
 Storage Driver: zfs
  Zpool: myraid1
  Zpool Health: ONLINE
  Parent Dataset: myraid1
  Space Used By Parent: 380262423552
  Space Available: 102384526336
  Parent Quota: no
  Compression: off
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.15.18-10-pve
 Operating System: Debian GNU/Linux 9 (stretch)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.55GiB
 Name: pve
 ID: CQY7:JPC7:E6UE:C452:2XYP:NWOA:WT46:AUZH:QTUS:5VXU:NYWD:6XK4
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

我们可以看到docker默认存储空间为/var/lib/docker

以下操作可以修改存储空间,前提是你的docker是刚安装,没有太多的镜像和容器

systemctl stop docker
rm -rf /var/lib/docker
ln -sv /media/www/docker /var/lib/docker
systemctl start docker

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

转载请注明:docker修改默认的存储路径/var/lib/docker 出自老鄢博客 | 欢迎分享