2

Install Docker on Ubuntu 22.04(LTS)

 1 year ago
source link: https://blog.51cto.com/wemux/5659185
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Install Docker on Ubuntu 22.04(LTS)

精选 原创

如果之前安装过旧版本Docker,需要先卸载。

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

卸载完成后,需要安装几个软件使得apt能够通过https安装软件。

sudo apt-get update

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

不过似乎都已经默认安装过了。

添加Docker的官方GPG密钥,好像是为了能够防止软件被篡改。

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

添加Docker软件源:

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

但是添加的源是国外的网站,根据经验来看速度必然很慢,因此刚才的代码应该改为:

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/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 docker-compose-plugin

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK