Docker 安装步骤 (Ubuntu)
sudo apt update
- Step 2: 安装依赖包【用于通过HTTPS来获取仓库】
sudo apt install apt-transport-https ca-certificates curl software-properties-common
- Step 3: 添加 Docker 官方 GPG 密钥
curl 是一个用于在命令行中传输数据的工具,支持多种协议,包括 HTTP、HTTPS、FTP 等
但是其在root下的运行很奇怪
sudo -i #用来在终端中以 root 用户的身份启动一个新的登录 shell
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/docker-ce.gpg
sudo apt-key fingerprint 0EBFCD88
- Step 5: 添加 Docker 阿里稳定版软件源
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
sudo docker run hello-world
sudo docker images
sudo usermod -aG docker galaxfy
su - galaxfy # 刷新shell状态
docker images # 验证用户组配置
其他 Docker 运行命令:
sudo systemctl status docker
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl stop docker
sudo apt-cache madison docker-ce # 显示可用版本
sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io # 将需要的版本替换 VERSION_STRING 进行安装, 例如 5:20.10.17~3-0~ubuntu-focal