Linux 上安装 Docker
对于 Linux,你可以使用各自的包管理器来安装 Docker。以 Ubuntu 为例,以下是安装步骤。
系统要求:
- 64位版本的 Ubuntu。
安装步骤:
-
更新你的包列表:
bash
复制代码
sudo apt-get update
-
安装依赖包:
bash
复制代码
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
-
添加 Docker 的官方 GPG 密钥:
bash
复制代码
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
-
设置 Docker 仓库:
bash
复制代码
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
-
更新包列表:
bash
复制代码
sudo apt-get update
-
安装 Docker:
bash
复制代码
sudo apt-get install docker-ce
-
安装完成后,你可以运行以下命令检查 Docker 是否安装成功:
bash
复制代码
sudo docker --version