Ubuntu安装docker

官方文档 推荐使用docker自己的apt源,不使用Ubuntu自带的docker源。

Ubuntu自带docker包卸载

sudo apt-get remove docker docker-engine docker.io containerd runc

更新系统 安装辅助工具

sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

添加docker官方的GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

添加docker源

x86_64 源

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

arm64源

echo \
  "deb [arch=arm64 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

从官方源安装docker

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

helloworld测试

sudo docker run hello-world

标签: ubuntu, docker

添加新评论