美文网首页
Install Docker CE 17.03.2 on Cen

Install Docker CE 17.03.2 on Cen

作者: 寺院的研究僧 | 来源:发表于2018-04-23 21:11 被阅读135次

    1. 挂载额外数据盘到/localdisk目录

    fdisk /dev/vdb
    n
    p
    wq
    mkfs.ext4 /dev/vdb1
    echo "/dev/vdb1            /localdisk           ext4       defaults              0 0" >>/etc/fstab
    mkdir -p /localdisk
    mount -a
    df -h
    

    2. 升级内核到4.4.127 LTS, 重启生效

    wget https://mirrors.tuna.tsinghua.edu.cn/elrepo/archive/kernel/el7/x86_64/RPMS/kernel-lt-4.4.127-1.el7.elrepo.x86_64.rpm;
    wget https://mirrors.tuna.tsinghua.edu.cn/elrepo/archive/kernel/el7/x86_64/RPMS/kernel-lt-devel-4.4.127-1.el7.elrepo.x86_64.rpm
    rpm -ivh kernel-lt-devel-4.4.127-1.el7.elrepo.x86_64.rpm
    rpm -ivh kernel-lt-4.4.127-1.el7.elrepo.x86_64.rpm;
    
    
    grub2-mkconfig -o /etc/grub2.cfg
    awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
    grub2-set-default 0 
    
    reboot
    

    3. 安装17.03.2二进制方式 或者 安装18.03.0 rpm包方式

    wget https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/docker-17.03.2-ce.tgz
    tar -zxvf docker-17.03.2-ce.tgz
    mv -f docker/* /usr/bin
    
    or 
    
    yum localinstall -y https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-18.03.0.ce-1.el7.centos.x86_64.rpm
    

    4. 设置 /etc/sysctl.conf

    modprobe bridge
    cat <<EOF >>/etc/sysctl.conf 
    net.ipv4.ip_forward = 1
    net.ipv4.ip_local_port_range = 32768 65535
    net.bridge.bridge-nf-call-ip6tables = 1
    net.bridge.bridge-nf-call-iptables = 1
    net.bridge.bridge-nf-call-arptables = 1
    EOF
    
    sysctl -p
    

    5.配置docker daemon

    
    mdkir -p /etc/docker
    cat <<EOF >/etc/docker/daemon.json
    {
        "hosts": [
            "tcp://0.0.0.0:2375",
            "unix:///var/run/docker.sock"
         ],
        "debug": false,
        "log-driver": "json-file",
        "log-level": "debug",
        "experimental": true,
        "metrics-addr": "0.0.0.0:1337",
        "selinux-enabled": false,
        "registry-mirrors": [
            "https://registry.docker-cn.com",
            "http://f631e5c5.m.daocloud.io",
            "https://kuamavit.mirror.aliyuncs.com",
            "https://docker.mirrors.ustc.edu.cn"
        ],
        "insecure-registries":[
            "gcr.io",
            "quay.io",
            "registry.cn-hangzhou.aliyuncs.com",
            "10.194.11.253",
            "10.194.11.253:5000"
        ],
        "exec-opts": [
            "native.cgroupdriver=cgroupfs"
        ],
        "graph": "/localdisk/docker/graph",
        "storage-driver": "overlay2",
        "storage-opts": [ "overlay2.override_kernel_check=true" ],
        "live-restore": false,
        "max-concurrent-downloads": 10,
        "log-driver": "json-file",
        "log-level": "warn",
        "log-opts": {
          "max-size": "10m",
          "max-file": "3"
        }
    }
    EOF
    
    

    6.启动 docker daemon

    cat <<EOF >/etc/systemd/system/docker.service
    [Unit]
    Description=Docker Application Container Engine
    Documentation=http://docs.docker.io
    
    [Service]
    ExecStart=/usr/bin/dockerd
    ExecStartPost=/sbin/iptables -I FORWARD -s 0.0.0.0/0 -j ACCEPT
    ExecReload=/bin/kill -s HUP $MAINPID
    Restart=on-failure
    RestartSec=5
    LimitNOFILE=infinity
    LimitNPROC=infinity
    LimitCORE=infinity
    Delegate=yes
    KillMode=process
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
    systemctl daemon-reload
    systemctl start docker 
    docker info
    
    

    7. 启动cAdvisor

    docker run --restart=always --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --publish=4033:8080 --detach=true --name=cadvisor google/cadvisor
    

    8. 启动VNC容器

    docker run -p 10080:80 -p 5900:5900 -e VNC_PASSWORD=vncpassword dorowu/ubuntu-desktop-lxde-vnc
    

    9. 安装docker-compose

    wget --no-check-certificate https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
    tar -zxvf Python-2.7.13.tgz
    cd Python-2.7.13
    ./configure
    make && make install
    
    
    wget https://bootstrap.pypa.io/get-pip.py 
    /usr/local/bin/python get-pip.py
    
    pip install --upgrade pip -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
    
    pip install --upgrade docker-compose -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
    

    相关文章

      网友评论

          本文标题:Install Docker CE 17.03.2 on Cen

          本文链接:https://www.haomeiwen.com/subject/buhrlftx.html