Docker 修改默认存储位置

Docker 修改默认存储位置

  • 首先使用 docker info 查看 docker 的基本信息
sudo docker info
Containers: 0
Images: 5
Storage Driver: devicemapper
 Pool Name: docker-253:0-679369-pool
 Pool Blocksize: 65.54 kB
 Backing Filesystem: extfs
 Data file: 
 Metadata file: 
 Data Space Used: 533.9 MB
 Data Space Total: 107.4 GB
 Data Space Available: 106.8 GB
 Metadata Space Used: 954.4 kB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.147 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Library Version: 1.02.89-RHEL6 (2014-09-01)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 2.6.32-431.29.2.el6.x86_64
Operating System: <unknown>
CPUs: 1
Total Memory: 853.5 MiB
Name: rhel62build
ID: LIO4:I43U:YFQU:SN45:YOE6:7GTF:6AGX:VSKQ:ICIV:AKWD:3OKQ:HUSC

这是一个新装的docker环境,其中看不出当前docker文件存储的路径。但是docker默认会使用 /var/lib/docker 作为默认存储位置。

  • 停止 Docker 服务
sudo /etc/init.d/docker stop
  • 将原来默认的/var/lib/docker备份一下,然后复制到别的位置并建立一个软链接
cd /var/lib
sudo cp -rf docker docker.bak
sudo cp -rf docker /<my_new_location>/
sudo ln -s /<my_new_location>/docker docker
  • 启动 Docker 服务
sudo /etc/init.d/docker start
  • 最后使用 docker info 查看更新结果
sudo docker info
Containers: 0
Images: 5
Storage Driver: devicemapper
 Pool Name: docker-8:21-393695-pool
 Pool Blocksize: 65.54 kB
 Backing Filesystem: extfs
 Data file: /dev/loop1
 Metadata file: /dev/loop2
 Data Space Used: 533.9 MB
 Data Space Total: 107.4 GB
 Data Space Available: 15.33 GB
 Metadata Space Used: 954.4 kB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.147 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Data loop file: /build/docker/devicemapper/devicemapper/data
 Metadata loop file: /build/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.89-RHEL6 (2014-09-01)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 2.6.32-431.29.2.el6.x86_64
Operating System: <unknown>
CPUs: 1
Total Memory: 853.5 MiB
Name: rhel62build
ID: LIO4:I43U:YFQU:SN45:YOE6:7GTF:6AGX:VSKQ:ICIV:AKWD:3OKQ:HUSC

转载请以链接形式标明本文地址
本文地址:http://blog.csdn.net/kongxx/article/details/50310653

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值