参考链接

Step 1 — Installing Docker

安装相关依赖

1
2
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common

添加 apt 软件源信息

根据主机服务商选择下列其中一项,不对号入座的话下载速度会比较慢

1
2
3
# 添加官方软件源信息(适用于海外主机)
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"
1
2
3
# (适用于境内阿里云主机)
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
1
2
3
# (适用于境内腾讯云主机)
curl -fsSL https://mirrors.cloud.tencent.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] http://mirrors.cloud.tencent.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

确认 docker-ce repo 信息

1
apt-cache policy docker-ce

安装 Docker

1
sudo apt install docker-ce

检查 Docker 运行状态

1
sudo systemctl status docker

Step 2 — Executing the Docker Command Without Sudo (Optional)

1
2
3
sudo usermod -aG docker ${USER}

su - ${USER}

Step 3 — Using the Docker Command

Step 4 — Working with Docker Images

Step 5 — Running a Docker Container