1、docker ubuntu安装
#如果你过去安装过docker,先删除
yzil@ubuntu01:~$ sudo apt-get remove docker docker-engine docker.io
#首次安装依赖
yzil@ubuntu01:~$ sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
#信任docker的GPG公钥
yzil@ubuntu01:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#1、对于amd64架构的计算机,添加软件仓库
yzil@ubuntu01:~$ sudo add-apt-repository \
> "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
> $(lsb_release -cs) \
> stable"
#2、如果你是树莓派或其它ARM架构计算机,请运行:
echo "deb [arch=armhf] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list
#最后安装
yzil@ubuntu01:~$ sudo apt-get update
yzil@ubuntu01:~$ sudo apt-get install docker-ce
2、docker centos 7的安装
#docker所有的操作都必须要使用root来完成!
#如果你之前安装过 docker,请先删掉
[root@cent7-1 ~]# yum remove docker docker-common docker-selinux docker-engine
#安装一些依赖
[root@cent7-1 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
#根据你的发行版下载repo文件:
[root@cent7-1 ~]# wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
#把软件仓库地址替换为 TUNA
[root@cent7-1 ~]# sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
#最后安装
#安装指定的docker-ce版本
[root@cent7-1 ~]# yum list docker-ce.x86_64 --showduplicates | sort -r
[root@cent7-1 ~]# yum -y install docker-ce-19.03.9-3.el7
[root@cent7-1 ~]# systemctl enable --now docker
3、docker centos 7一键脚本的安装
[root@cent7_6 ~]# cat install_docker_for_centos7.sh
#!/bin/bash
COLOR="echo -e \\033[1;31m"
END="\033[m"
VERSION="19.03.9-3.el7"
wget -P /etc/yum.repos.d/ https://download.docker.com/linux/centos/docker-ce.repo || { ${COLOR}"互联网连接失败,请检查网络配置!"${END};exit;}
sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
yum clean all
yum -y install docker-ce-$VERSION || { ${COLOR} " yum源配置失败,请检查yum源配置 "${END};exit;}
mkdir -p /etc/docker
cat > /usr/lib/systemd/system/docker.service << EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
[Service]
Type=notify
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process
[Install]
WantedBy=multi-user.target
EOF
systemctl restart docker
docker version && ${COLOR}"Docker安装成功"${END} || ${COLOR}"Docker安装失败"${END}
[root@cent7_6 ~]#
|