• linux运维、架构之路-Docker修改本地镜像存储位置


    一、方法一:

    1、查看Docker默认存放数据目录

    [root@k8s-node1 tools]# docker info | grep "Docker Root Dir"
    WARNING: API is accessible on http://127.0.0.1:4243 without encryption.
             Access to the remote API is equivalent to root access on the host. Refer
             to the 'Docker daemon attack surface' section in the documentation for
             more information: https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
     Docker Root Dir: /var/lib/docker

    2、停止Docker服务

     systemctl stop docker

    3、移动Docker数据目录到指定的分区

    [root@k8s-node1 app]# mv /var/lib/docker /app/data/docker    #这里/app为挂载的网络存储NAS
    [root@k8s-node1 app]# ln -s /app/data/docker /var/lib/docke  #软链接到原来的目录

    4、启动Docker服务查看存储目录

    systemctl start docker
    [root@k8s-node1 ~]# docker info|grep "Docker Root Dir"
    WARNING: API is accessible on http://127.0.0.1:4243 without encryption.
             Access to the remote API is equivalent to root access on the host. Refer
             to the 'Docker daemon attack surface' section in the documentation for
             more information: https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
     Docker Root Dir: /app/data/docker

     方法二:

    1、/usr/lib/systemd/system/docker.service启动服务文件中指定

    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network-online.target firewalld.service
    Wants=network-online.target
    
    [Service]
    Type=notify
    # the default is not to use systemd for cgroups because the delegate issues still
    # exists and systemd currently does not support the cgroup feature set required
    # for containers run by docker
    ExecStart=/usr/bin/dockerd --exec-opt native.cgroupdriver=systemd --data-root=/data/docker_data 
                 --insecure-registry=hub.ityy.ultrapower.com.cn:5050 
                 $DOCKER_NETWORK_OPTIONS
    ExecReload=/bin/kill -s HUP $MAINPID
    # Having non-zero Limit*s causes performance problems due to accounting overhead
    # in the kernel. We recommend using cgroups to do container-local accounting.
    LimitNOFILE=infinity
    LimitNPROC=infinity
    LimitCORE=infinity
    # Uncomment TasksMax if your systemd version supports it.
    # Only systemd 226 and above support this version.
    #TasksMax=infinity
    TimeoutStartSec=0
    # set delegate yes so that systemd does not reset the cgroups of docker containers
    Delegate=yes
    # kill only the docker process, not all processes in the cgroup
    KillMode=process
    # restart the docker process if it exits prematurely
    Restart=on-failure
    StartLimitBurst=3
    StartLimitInterval=60s
    EnvironmentFile=-/run/flannel/docker
    [Install]
    WantedBy=multi-user.target

    2、查看是否生效

    docker info|grep Dir
    Docker Root Dir: /data/docker_data
  • 相关阅读:
    [LeetCode]String主题系列{第5,6题}
    [LeetCode]Math主题系列{第7,9,13,273题}
    [LeetCode]LinkedList主题系列{第2题}
    [LeetCode]HashTable主题系列{第3,36,49,94,136,138,187,202,204,205,290,347,389,409,438,451,463,500,508,560,594,599题}
    由于博客园的道路越来越像CSDN了,已经不再是当年的博客园了,决定退出博客园,后续建立自己的博客站点。
    Revit二次开发——非模态窗口的事件处理
    Revit二开---Schemachema扩展数据
    Revit二开---ViewFamily视图类型枚举
    CAD二开---扩展数据XData
    CAD二开---框选文字批量对齐
  • 原文地址:https://www.cnblogs.com/yanxinjiang/p/12155005.html
Copyright © 2020-2023  润新知