• DOCKER 从入门到放弃(四)


    更改docker 存储的路径

    在如下版本及环境验证过:

    [root@docker opt]# uname -a
    Linux docker 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
    [root@docker opt]# rpm -qa|grep docker
    docker-common-1.12.6-55.gitc4618fb.el7.centos.x86_64
    docker-client-1.12.6-55.gitc4618fb.el7.centos.x86_64
    docker-1.12.6-55.gitc4618fb.el7.centos.x86_64
    

    创建软件来修改路径

    rpm安装的docker的存储路径默认设置为:/var/lib/docker,可以使用docker info命令查看

    [root@docker containers]# docker info|grep Root
     WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
    Docker Root Dir: /var/lib/docker
    

    停止docker运行

    [root@docker containers]# systemctl stop docker
    

    将存储目录移动到指定路径(不移动原来的目录将创建一个全新的存储空间)

    [root@docker containers]# cp /var/lib/docker /opt/ -rf
    

    创建软链接

    [root@docker ~]# cd /var/lib/
    [root@docker lib]# pwd
    /var/lib
    [root@docker lib]# mv docker docker_bak
    [root@docker lib]# ln -s /opt/docker docker
    [root@docker lib]# ll docker
    lrwxrwxrwx 1 root root 11 Oct  9 23:13 docker -> /opt/docker
    

    启动docker并验证是否更改成功

    [root@docker lib]# systemctl start docker
    [root@docker lib]# docker info|grep Root
     WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
    Docker Root Dir: /opt/docker
    

    修改docker 启动参数更改存储路径

    rpm安装的docker的存储路径默认设置为:/var/lib/docker,可以使用docker info命令查看

    [root@docker containers]# docker info|grep Root
     WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
    Docker Root Dir: /var/lib/docker
    

    停止docker运行

    [root@docker containers]# systemctl stop docker
    

    将存储目录移动到指定路径(不移动原来的目录将创建一个全新的存储空间)

    [root@docker containers]# cp /var/lib/docker /opt/ -rf
    

    添加--graph启动参数指定存储路径

    [root@docker opt]# cat /etc/sysconfig/docker|grep -v "^#"
    
    OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --graph=/opt/docker-1'
    if [ -z "${DOCKER_CERT_PATH}" ]; then
        DOCKER_CERT_PATH=/etc/docker
    fi
    

    也可以修改/usr/lib/systemd/system/docker.service 文件,但是要使用systemctl daemon-reload重载配置文件

    启动docker并验证是否更改成功

    [root@docker lib]# systemctl start docker
    [root@docker lib]# docker info|grep Root
     WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
    Docker Root Dir: /opt/docker
    
  • 相关阅读:
    jar包和war包的介绍和区别
    Jenkins安装完成后,一直停留在页面Please wait while Jenkins is getting ready to work...的解决方法
    mongdb简介
    loadrunner12的安装教程
    airpods2隐藏的使用技巧(十)点
    银行个人住房贷款LPR办理流程-建行app
    一张图了解地摊经济时代如何摆摊
    每天学五分钟 Liunx 001 | 用户及用户组
    每天学五分钟 Liunx 000 | 计算机与 Liunx
    【转载】资深大牛吐血总结:如何成为一名合格的云架构师?
  • 原文地址:https://www.cnblogs.com/panjunbai/p/7645643.html
Copyright © 2020-2023  润新知