一、CentOS安装Docker
使用安装脚本安装
sudo yum update
curl -fsSL https://get.docker.com/ | sh
systemctl start docker
systemctl enable docker
手动安装
卸载原有版本
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
安装Docker依赖库
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
安装Docker引擎
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl start docker
sudo systemctl enable docker
docker run hello-world
二、Ubuntu安装Docker
使用安装脚本安装
# 保证机器没有安装过docker
# 如果没安装过docker这步可以省略
sudo apt-get purge docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
# 下载安装脚本并运行
sudo apt update
curl -fsSL https://get.docker.com | sh
systemctl start docker
systemctl enable docker
手动安装
安装Docker依赖库
sudo apt-get -y install ca-certificates curl gnupg lsb-release
# 添加Docker pgp密钥 二选一
# 国内源
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | \
sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# 官方源
curl -fsSL https://download.docker.com/linux/debian/gpg | \
sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# 添加Docker apt源 二选一
# 国内源
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 官方源
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
安装Docker引擎
sudo apt-get update -y
sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
docker run hello-world
三、配置国内镜像源
# 配置阿里云镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://7kcin9o3.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo docker info
其他推荐加速地址
名称 | 地址 |
---|---|
中国区官方镜像 | https://registry.docker-cn.com |
网易 | http://hub-mirror.c.163.com |
ustc | https://docker.mirrors.ustc.edu.cn |
中国科技大学 | https://docker.mirrors.ustc.edu.cn |
阿里云容器 | https://cr.console.aliyun.com/ |
四、安装docker-compose
curl -SL https://github.com/docker/compose/releases/download/v2.19.0/docker-compose-linux-x86_64
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
docker-compose version
标签:发行版,安装,sudo,https,Linux,Docker,com,docker From: https://www.cnblogs.com/ronnybox/p/17516322.html官方安装链接:https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
安装过程报错解决方法:https://www.baidu.com/