yum -y install epel-release
yum -y install docker
docker version
docker版本資訊:
client:
version: 1.13.1
api version: 1.26
package version: docker-1.13.1-94.gitb2f74b2.el7.centos.x86_64
go version: go1.10.3
git commit: b2f74b2/1.13.1
built: tue mar 12 10:27:24 2019
os/arch: linux/amd64
server:
version: 1.13.1
api version: 1.26 (minimum version 1.12)
package version: docker-1.13.1-94.gitb2f74b2.el7.centos.x86_64
go version: go1.10.3
git commit: b2f74b2/1.13.1
built: tue mar 12 10:27:24 2019
os/arch: linux/amd64
experimental: false
檢視docker資訊:
docker info
輸出如下:
containers: 1
running: 0
paused: 0
stopped: 1
images: 1
server version: 1.13.1
storage driver: overlay2
backing filesystem: xfs
supports d_type: true
native overlay diff: true
logging driver: journald
cgroup driver: systemd
plugins:
volume: local
network: bridge host macvlan null overlay
swarm: inactive
runtimes: docker-runc runc
default runtime: docker-runc
init binary: /usr/libexec/docker/docker-init-current
containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: df5c38a9167e87f53a9894d77c0950e178a745e7 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
security options:
seccomp
warning: you're not using the default seccomp profile
profile: /etc/docker/seccomp.json
kernel version: 3.10.0-862.14.4.el7.x86_64
operating system: centos linux 7 (core)
ostype: linux
architecture: x86_64
number of docker hooks: 3
cpus: 1
total memory: 991.7 mib
name: fuqiang
id: f2md:skqc:hszg:ln7h:l3ki:7sn2:jhrp:hmqi:3kk2:4rto:tptj:ucyz
docker root dir: /var/lib/docker
debug mode (client): false
debug mode (server): false
registry:
experimental: false
insecure registries:
127.0.0.0/8
live restore enabled: false
registries: docker.io (secure)
上面的輸出資訊中,docker root dir: /var/lib/docker,就是映象與容器例項的預設儲存位置;
容器映象目標位置:/home/
停止docker服務:
systemctl stop docker
資料遷移:
cp -a /var/lib/docker/ /home/
資料備份:
mv /var/lib/docker /var/lib/docker.bak
docker server version: 1.13.1通過修改/etc/docker/daemon.json檔案中的引數變更映象與容器例項的預設儲存位置;
cd /etc/docker/
yum -y install vim
/etc/docker/daemon.json原檔案:
{}
/etc/docker/daemon.json檔案修改後:
啟動docker服務:
systemctl start docker
systemctl status docker
檢視docker info資訊:
docker info
輸入如下:
containers: 0
running: 0
paused: 0
stopped: 0
images: 0
server version: 1.13.1
storage driver: overlay2
backing filesystem: xfs
supports d_type: true
native overlay diff: true
logging driver: journald
cgroup driver: systemd
plugins:
volume: local
network: bridge host macvlan null overlay
swarm: inactive
runtimes: docker-runc runc
default runtime: docker-runc
init binary: /usr/libexec/docker/docker-init-current
containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: df5c38a9167e87f53a9894d77c0950e178a745e7 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
security options:
seccomp
warning: you're not using the default seccomp profile
profile: /etc/docker/seccomp.json
selinux
kernel version: 3.10.0-862.el7.x86_64
operating system: centos linux 7 (core)
ostype: linux
architecture: x86_64
number of docker hooks: 3
cpus: 4
total memory: 7.455 gib
name: localhost.localdomain
id: 4vkw:3eps:szht:uaxv:agno:twfn:cg6u:um3i:yyjk:ns7a:indk:2q3c
docker root dir: /home/docker
debug mode (client): false
debug mode (server): false
registry:
experimental: false
insecure registries:
127.0.0.0/8
live restore enabled: false
registries: docker.io (secure)
通過如上輸入,我們發現:
docker root dir: /home/docker
說明容器映象與例項預設的儲存位置已經變更了。
修改Docker映象的預設儲存位置
可以全域性搜尋該檔案的名稱 find name docker.service 打算更改配置之前,如果伺服器上已經啟動了一些docker容器,需要先關閉 docker compose f yml down 這些容器,並關閉docker服務 systemctl stop docker 如果不這麼做,可能...
修改Docker預設映象和容器的儲存位置
docker預設的映象和容器儲存位置在 var lib docker中,如果僅僅是做測試,我們可能沒有必要修改,但是當大量使用的時候,我們可能就要預設儲存的位置了。cd etc systemd system multi user.target.wants vim docker.service exe...
docker修改預設儲存位置
docker 預設是將資料儲存在 var lib docker下,因此當機器儲存的映象比較多,或者執行的映象比較多時,會將系統儲存佔滿 系統儲存一般都只會分配很小的空間,僅保證系統執行 因此我們需要將docker的資料轉移到資料磁碟上。1 停止docker服務 2 將 var lib docker轉...