安装 Docker
1. 卸载旧版本
sudo apt-get remove docker docker-engine docker.io containerd runc
2. 安装基本软件
sudo apt update
sudo apt install apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
3. 添加Docker官方的GPG密钥并添加库
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) 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
4. 安装Docker
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
非 root 账户下 不使用 sudo 执行 Docker 命令
1. 创建docker 用户组
sudo gpasswd -a ${USER} docker
2. 重启docker服务
sudo systemctl restart docker
3. 重新登录生效
配置 Docker-compose
1. 下载
sudo curl -L "https://github.com/docker/compose/releases/download/v2.1.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2. 添加执行权限添加执行软链
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose