1. 程式人生 > >Docker修改預設儲存位置

Docker修改預設儲存位置

先Docker info 檢視基本資訊

[email protected]:~# docker info 
Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 39
Server Version: 18.05.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: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-124-generic
Operating System: Ubuntu 16.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 15.66GiB
Name: allbak
ID: WDR7:SQTX:YHIB:2UCU:EY4X:RFST:INQY:EBGT:HO7M:4WFU:XXBI:YXSW
Docker Root Dir:

docker預設位置/var/lib/docker

以下是修改步驟:

1.停止docker

[email protected]:~# /etc/init.d/docker stop

2.遷移Docker路徑  

[email protected]:~# cd /var/lib/
[email protected]:~# mv docker /media/sdj1/

3.建立軟連線

ln -s /media/sdj1/docker docker

4.啟動docker

[email protected]:~# /etc/init.d/docker start

5.docker info 再次檢視資訊

[email protected]:/var/lib/docker# docker info             
Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 39
Server Version: 18.05.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: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-124-generic
Operating System: Ubuntu 16.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 15.66GiB
Name: allbak
ID: WDR7:SQTX:YHIB:2UCU:EY4X:RFST:INQY:EBGT:HO7M:4WFU:XXBI:YXSW
Docker Root Dir: /media/sdj1/docker