- Published on
Ubuntu Install Docker
- Authors
- Name
- Piggy DP
- @xiaozhudxiaozhu
更新软件包
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
添加docker官网 GPG 密钥、设置stable 仓库
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
由于网络问题,上面的操作可能会报错,我们使用以下命令,使用阿里云的stable仓库
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
安装 Docker
docker --version
sudo systemctl status docker
给Docker设置镜像加速
vim /etc/docker/daemon.json
在网上搜索当前可用的docker registry-mirrors ,因为有些镜像源经常失效,这里不再具体陈述
{
"registry-mirrors": []
}
加载daemon文件,重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker
卸载docker
docker container stop $(docker container ls -aq)
docker system prune -a --volumes
sudo apt-get purge docker-ce docker-ce-cli containerd.io
sudo apt autoremove