linux怎么安装docker

admin 阅读:49 2024-06-19
如何在 linux 上安装 docker?步骤如下:检查先决条件:内核版本 3.10+、ram ≥ 2gb、稳定网络。安装依赖项:ubuntu/debian:apt-get install apt-transport-https...;centos/red hat:yum install yum-utils...添加 docker 官方仓库:ubuntu/debian:curl... | apt-key add -;centos/red hat:yum-config-manager --add-

linux怎么安装docker

如何在 Linux 上安装 Docker

第一步:检查先决条件

  • Linux 内核版本 3.10 或更高版本
  • 至少 2GB 的 RAM
  • 稳定的互联网连接

第二步:安装 Docker 依赖项

  • Ubuntu/Debian:

    sudo apt-get update
    sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  • CentOS/Red Hat:

    sudo yum install -y yum-utils device-mapper-persistent-data lvm2

第三步:添加 Docker 官方仓库

  • Ubuntu/Debian:

    sudo curl -fsSL https://download.<a style="color:#f60; text-decoration:underline;" href="https://www.codesou.cn/" target="_blank">docker</a>.com/<a style="color:#f60; text-decoration:underline;" href="https://www.codesou.cn/" target="_blank">linux</a>/ubuntu/gpg | sudo apt-key add -
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  • CentOS/Red Hat:

    sudo yum-config-manager --add-repo https://download.docker.com/linux/<a style="color:#f60; text-decoration:underline;" href="https://www.codesou.cn/" target="_blank">centos</a>/docker-ce.repo

第四步:安装 Docker

  • Ubuntu/Debian:

    sudo apt-get update
    sudo apt-get install docker-ce
  • CentOS/Red Hat:

    sudo yum install docker-ce

第五步:启动 Docker

  • Ubuntu/Debian:

    sudo systemctl start docker
  • CentOS/Red Hat:

    sudo systemctl start docker

第六步:验证安装

运行以下命令检查 Docker 是否已成功安装:

docker run hello-world

如果看到类似于以下内容的输出,则表示 Docker 已成功安装:

Hello from Docker!
This message shows that your installation appears to be working correctly.
声明

1、部分文章来源于网络,仅作为参考。
2、如果网站中图片和文字侵犯了您的版权,请联系1943759704@qq.com处理!