美文网首页
docker安装

docker安装

作者: Odven | 来源:发表于2020-06-02 16:05 被阅读0次

    参考 https://docs.docker.com/engine/install/

    卸载久版本

    yum remove docker
    docker-client
    docker-client-latest
    docker-common
    docker-latest
    docker-latest-logrotate
    docker-logrotate
    docker-engine

    1) 使用yum源安装

    yum install -y yum-utils
    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    
    yum install docker-ce docker-ce-cli containerd.io  # 这是安装最新版
    
    或
    yum list docker-ce --showduplicates | sort -r  # 可以使用这里命令查看docker的不同版本然后有选择的安装
    yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
    
    systemctl start docker  # 启动docker
    docker run hello-world  # 测试docker
    

    2). 使用rpm包安装

    下载地址 https://download.docker.com/linux/centos/
    下载相应的docker-ce,docker-ce-cli,containerd.io的rpm包到本地安装
    yum install /path/to/package.rpm
    

    3). 使用二进制包安装

    下载地址 https://download.docker.com/linux/static/stable/
    下载相应的版本的二进制包到本地安装
    tar xzvf /path/to/<FILE>.tar.gz
    cp -r docker/*  /usr/local/bin/
    
    配置systemd
    cat > /usr/lib/systemd/system/docker.service  << EOF
    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network-online.target firewalld.service containerd.service
    Wants=network-online.target
    
    [Service]
    Type=notify
    ExecStart=/usr/local/bin/dockerd
    ExecReload=/bin/kill -s HUP $MAINPID
    TimeoutSec=0
    RestartSec=2
    Restart=always
    StartLimitBurst=3
    StartLimitInterval=60s
    LimitNOFILE=infinity
    LimitNPROC=infinity
    LimitCORE=infinity
    TasksMax=infinity
    Delegate=yes
    KillMode=process
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
    systemctl daemon-reload
    systemctl restart docker.service
    

    4). 使用脚本安装

    curl -fsSL https://get.docker.com -o get-docker.sh
    sh get-docker.sh
    

    5). 配置docker加速

    cat /etc/docker/daemon.json
    {
    "data-root": "/mnt/docker-data",
    "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"],
    "insecure-registries": ["192.168.192.100:5000"],
    "log-driver":"json-file",
    "log-opts": {"max-size":"50m", "max-file":"2"},
    "storage-driver": "overlay2"
    }
    

    相关文章

      网友评论

          本文标题:docker安装

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