> 本文作者:丁辉 # Ubuntu网络源安装Containerd ## Ubuntu部署Containerd配置Apt源 > 我部署 containerd 的时候遇到了各个版本 apt 源无法下载的问题,所以本次记录 Ubuntu 源配置步骤 ### 安装必须源 ```bash apt -y install apt-transport-https ca-certificates curl software-properties-common ``` ### Ubuntu 22.04(现代添加推荐方法) ```bash curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 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 ``` ### Ubuntu 21.10(传统添加方法) ```bash 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 impish stable" ``` ### Ubuntu 21.04(传统添加方法) ```bash 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 hirsute stable" ``` ### Ubuntu 20.10 (传统添加方法) ```bash 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 groovy stable" ``` ### Ubuntu 20.04(传统添加方法) ```bash 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" ``` ### Ubuntu 19.10 (传统添加方法) ```bash 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 eoan stable" ``` ### Ubuntu 19.04(传统添加方法) ```bash 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 disco stable" ``` ### Ubuntu 18.10(传统添加方法) ```bash 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 cosmic test" ``` ### Ubuntu 18.04(传统添加方法) ```bash 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 bionic stable" ``` ### Ubuntu 17.10(传统添加方法) ```bash 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 artful stable" ``` ### Ubuntu 16.04(传统添加方法) ```bash 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 xenial stable" ``` ## 开始安装 1. 更新包索引 ```bash apt update ``` 2. 安装 Containerd ```bash apt install containerd.io -y ``` 3. 配置 Containerd ```bash mkdir -p /etc/containerd ``` 使用默认配置文件 ```bash containerd config default | tee /etc/containerd/config.toml ``` 4. 修改驱动和镜像地址 ```bash vi /etc/containerd/config.toml ``` 内容如下(已更新为最新版配置方法,旧版层级不同) ```toml [plugins] ... [plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runc.options] SystemdCgroup = true # 修改这里用于配置容器运行时使用 systemd 作为 cgroup 驱动 的关键设置 [plugins.'io.containerd.cri.v1.images'.pinned_images] sandbox = 'registry.aliyuncs.com/google_containers/pause:3.10.1' ``` 5. 启动 ```bash systemctl enable containerd systemctl start containerd systemctl status containerd ``` 6. 验证 ```bash ctr info ```