ubuntu20.04 安装docker

  1. 安装配置环境

sudo groupadd docker
sudo usermod -a -G docker 当前用户名
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo reboot
  1. 更改docker国内镜像

sudo mkdir /etc/docker
sudo nano /etc/docker/daemon.json

daemon.json文件写入如下

{
    "registry-mirrors": [
        "https://docker.mirrors.ustc.edu.cn",
        "https://registry.docker-cn.com",
        "https://hub-mirror.c.163.com",
        "https://mirror.ccs.tencentyun.com"
    ]
}

重启docker以刷新docker镜像配置:

sudo systemctl daemon-reload 
sudo systemctl restart docker

查询镜像是否生效

docker info 
ubuntu20.04 安装docker_第1张图片
  1. 运行hello-world

docker run -i -t hello-world
ubuntu20.04 安装docker_第2张图片

你可能感兴趣的:(系统应用基础教程,容器)