CentOs/Ubuntu 一行指令安装Docker

CentOs方式

yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo \
    && sed -i 's+download.docker.com+mirrors.cloud.tencent.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo \
    && yum install docker-ce -y && sudo systemctl --now enable docker && touch /etc/docker/daemon.json \
    && echo "{\"registry-mirrors\":[\"https://mirror.ccs.tencentyun.com\"]}" > /etc/docker/daemon.json \
    && systemctl restart docker && docker run --rm hello-world && docker system prune -a --force

Ubuntu方式

sudo apt-get update && sudo apt-get install ca-certificates curl gnupg -y \
    && curl -fsSL https://mirrors.cloud.tencent.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - \
    && sudo add-apt-repository "deb [arch=amd64] https://mirrors.cloud.tencent.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" -y \
    && sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io -y \
    && sudo systemctl --now enable docker && sudo touch /etc/docker/daemon.json \
    && sudo sh -c 'echo "{\"registry-mirrors\":[\"https://mirror.ccs.tencentyun.com\"]}" > /etc/docker/daemon.json' \
    && sudo systemctl restart docker && sudo docker run --rm hello-world \
    && sudo docker system prune -a --force

你可能感兴趣的:(docker,centos,ubuntu,docker)