最新ubuntu20.04安装docker流畅教程
最新ubuntu20.04安装docker流畅教程
使用清华镜像源
//编辑/etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
开始部署
##读取数据源,安装依赖包
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
##使用下面的 curl 导入源仓库的GPG key:
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
##将 Docker APT 软件源添加到你的系统:
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
##安装docker
sudo apt install docker-ce docker-ce-cli containerd.io
##添加当前用户到docker组
sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo service docker restart
newgrp - docker
sudo chmod o+rw /var/run/docker.sock
##配置阿里云镜像加速器,追加了“https://docker.yccp.site"一个拉取镜像地址,防止报错
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://750xi8h6.mirror.aliyuncs.com","https://docker.yccp.site"]
}
EOF
#重新加载,重启服务
sudo systemctl daemon-reload
sudo systemctl restart docker
##测试拉取镜像,成功
uto@uto:~$ docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
bc0965b23a04: Pull complete
650ee30bbe5e: Pull complete
8cc1569e58f5: Pull complete
362f35df001b: Pull complete
13e320bf29cd: Pull complete
7b50399908e1: Pull complete
57b64962dd94: Pull complete
Digest: sha256:fb197595ebe76b9c0c14ab68159fd3c08bd067ec62300583543f0ebda353b5be
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
uto@uto:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 66f8bdd3810c 3 weeks ago 192MB
采用大神博客
ubuntu 安装 docker教程和使用
Ubuntu 20.04 安装docker(傻瓜试一键教程)