centos 下安装 docker
yum update -y
#清除旧的docker
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
#安装docker依赖
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
#添加docker官方源
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
#安装最新版docker
yum install docker-ce -y
#使用阿里加速镜像
#sudo mkdir -p /etc/docker
#sudo tee /etc/docker/daemon.json <<-'EOF'
#{
# "registry-mirrors": ["https://自己去阿里云申请,免费的"]
#}
#EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl enable docker
#推荐安装portainer管理docker
sudo docker run -d -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name main-portainer portainer/portainer
Bash
Copy
如果service firewalld status
查看防火墙打开的话,建议关闭
systemctl stop firewalld
systemctl disable firewalld
None
Copy
如果yum install docker-ce -y
报错
Problem: package docker-ce-3:19.03.3-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
None
Copy
则需要运行下面安装containerd.io-1.2.6
yum install -y https://download.docker.com/linux/centos/7/x86_64/edge/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
None
Copy
ubuntu 下安装 docker
#清除旧的docker
sudo apt-get remove docker docker-engine docker.io
#安装docker依赖
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
#添加密码指纹
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
#添加仓库
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
#根据官方指导刷新软件库会报错没有公钥,以下操作网上查到的
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F76221572C52609D
sudo apt-get clean
#再次刷新软件库
sudo apt-get update
#安装最新版docker
sudo apt-get -y install docker-ce
#使用阿里加速镜像
#sudo mkdir -p /etc/docker
#sudo tee /etc/docker/daemon.json <<-'EOF'
#{
# "registry-mirrors": ["https://自己去阿里云申请,免费的"]
#}
#EOF
#推荐安装portainer管理docker
sudo docker run -d -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name main-portainer portainer/portainer
Bash
Copy
debian 下安装 docker
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce
sudo systemctl status docker
Bash
Copy
alpine下安装 docker
需要事先修改镜像地址文件/etc/apk/repositories
把community
结尾的地址 去除 #
注释
# 新增一条`community`地址,需要更新一下
apk update
# 安装 docker
apk add docker
# 设置 docker 开机启动服务
rc-update add docker boot
# 开始运行docker
service docker start
#使用阿里加速镜像
#sudo mkdir -p /etc/docker
#sudo tee /etc/docker/daemon.json <<-'EOF'
#{
# "registry-mirrors": ["https://自己去阿里云申请,免费的"]
#}
#EOF
#推荐安装portainer管理docker
docker run -d -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name main-portainer portainer/portainer
如果出现CentOS 安装 Docker 报错
宝塔面板一键docker部署
来源:oschina
链接:https://my.oschina.net/u/152351/blog/3192469