美文网首页
二进制安装docker

二进制安装docker

作者: Nick_4438 | 来源:发表于2018-07-30 10:27 被阅读0次

    前言

    本文介绍如何在centos 7下二进制安装dokcer安装docker 版本为Docker version 18.03.1-ce, build 9ee9f40。

    操作步骤

    • 下载解压docker
    wget https://download.docker.com/linux/static/stable/x86_64/docker-18.03.1-ce.tgz
    tar -xvf docker-18.03.1-ce.tgz
    

    https://download.docker.com/linux/static/stable/x86_64/docker-17.03.2-ce.tgz

    • 拷贝二进制文件到指定目录
    chmod +x docker-18.03.1-ce/*
    cp docker-18.03.1-ce/* /usr/local/bin
    
    • 生成docker.service的文件并设定到/usr/lib/systemd/system目录下
    cat > /usr/lib/systemd/system/docker.service <<"EOF"
    [Unit]
    Description=Docker Application Container Engine
    Documentation=http://docs.docker.io
    [Service]
    Environment="PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
    EnvironmentFile=-/run/flannel/docker
    ExecStart=/usr/local/bin/dockerd --log-level=error $DOCKER_NETWORK_OPTIONS
    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 restart docker    # 为了多次执行可以顺利使用restart
    
    systemctl enable docker
    
    • 结果确认docker version

    • 安装docker-compose

    curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose
    

    快速安装脚本

    #!/bin/bash
    wget https://download.docker.com/linux/static/stable/x86_64/docker-18.03.1-ce.tgz
    tar -xvf docker-18.03.1-ce.tgz
    chmod +x docker-18.03.1-ce/*
    cp docker-18.03.1-ce/* /usr/local/bin/
    cat > /usr/lib/systemd/system/docker.service <<"EOF"
    [Unit]
    Description=Docker Application Container Engine
    Documentation=http://docs.docker.io
    
    [Service]
    Environment="PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
    EnvironmentFile=-/run/flannel/docker
    ExecStart=/usr/local/bin/dockerd --log-level=error $DOCKER_NETWORK_OPTIONS
    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 restart docker
    systemctl enable docker
    
    curl -L https://get.daocloud.io/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose
    

    国内

    vi /etc/docker/daemon.json

    {
    "registry-mirrors": ["https://registry.docker-cn.com"]
    }
    
    systemctl daemon-reload 
    systemctl restart docker
    

    相关文章

      网友评论

          本文标题:二进制安装docker

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