修改Docker默认存储路径

环境centos6.10,version: 1.7.1
修改docker默认存储路径防止镜像太多太大,也方便管理。
[root@hl-qy ~]# docker info
Containers: 0
Images: 0
Storage Driver: devicemapper
Pool Name: docker-253:1-1033069-pool
Pool Blocksize: 65.54 kB
Backing Filesystem: extfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 305.7 MB
Data Space Total: 107.4 GB
Data Space Available: 24.51 GB
Metadata Space Used: 729.1 kB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.147 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.117-RHEL6 (2016-12-13)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 2.6.32-358.6.2.el6.x86_64
Operating System: <unknown>
CPUs: 1
Total Memory: 1.96 GiB
Name: hl-qy
ID: CMYG:IGVE:WZM3:U22U:5S56:JQH3:VZO2:CH3G:WHBZ:XXRY:UXDR:ZP5A
[root@hl-qy ~]# yum list installed | grep docker
docker-io.x86_64 1.7.1-2.el6 @epel
[root@hl-qy ~]# docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d/1.7.1
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d/1.7.1
OS/Arch (server): linux/amd64

查到默认的信息后接下来修改

# mkdir /data

# /etc/init.d/docker stop

# cd /var/lib

# cp –rf docker /data

# rename ./docker/ ./docker_old ./docker/

# ln –s /data/docker  docker

# /etc/init.d/docker start

重启后再查询下

# docker info

Data loop file: /data/docker/devicemapper/devicemapper/data
Metadata loop file: /data/docker/devicemapper/devicemapper/metadata

恭喜已经修改成功

此条目发表在服务器分类目录,贴了标签。将固定链接加入收藏夹。

发表回复