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-ce
如果service firewalld status
查看防火墙打开的话,建议关闭
systemctl stop firewalld
systemctl disable firewalld
如果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
则需要运行下面安装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
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-ce
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
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-ce
windows 下配置 portainer
运行
docker run -d -p 9000:9000 --restart=always --name main-portainer portainer/portainer
配置里打开Expose daemon on tcp://localhost:2375 without TLS
重启docker 和 容器
然后 portainer 连接里选择 remote
地址填docker.for.win.localhost:2375
protainer 配置 https
mkdir ~/local-certs
cd ~/local-certs
openssl genrsa -out portainer.key 2048
openssl ecparam -genkey -name secp384r1 -out portainer.key
openssl req -new -x509 -sha256 -key portainer.key -out portainer.crt -days 3650
#部署portainer服务
docker run -d -p 9000:9000 --name portainer --restart always \
-v ~/local-certs:/certs \
-v portainer_data:/data \
-v /var/run/docker.sock:/var/run/docker.sock \
portainer/portainer \
--ssl --sslcert /certs/portainer.crt --sslkey /certs/portainer.key
#停用服务
docker stop portainer
docker rm portainer
curl -sSL https://get.docker.com/ | sh
ERROR: Unsupported distribution 'alpine'