centos7离线安装docker (二进制)
一、离线安装
新建路由
windos:route add 10.2.101.0 mask 255.255.255.0 160.5.1.254 ssh 10.2.101.19 rancher01-1
离线安装docker
https://download.docker.com/linux/static/stable/x86_64/ 下载离线包地址
https://download.docker.com/linux/static/stable/aarch64/
https://docs.docker.com/engine/install/binaries/
1 setup
cd /usr/local/resource/docker tar -xvf docker-19.03.4.tgz mv docker/* /usr/bin/ # 将二进制文件移动到bin下
2 systemd docker.service
vim /etc/systemd/system/docker.service
3 然后将以下内容粘贴进去(通用):
[Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock ExecReload=/bin/kill -s HUP $MAINPID # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity # Uncomment TasksMax if your systemd version supports it. # Only systemd 226 and above support this version. #TasksMax=infinity TimeoutStartSec=0 # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate=yes # kill only the docker process, not all processes in the cgroup KillMode=process # restart the docker process if it exits prematurely Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target
4 授予执行权限:
chmod +x /etc/systemd/system/docker.service
5 重新加载:
systemctl daemon-reload systemctl start docker systemctl enable docker.service
6 测试是否成功:
systemctl status docker docker -v
rpm方式安装
rpm -ivh containerd.io-1.2.2-3.el7.x86_64.rpm rpm -ivh container-selinux-2.107-3.el7.noarch.rpm rpm -ivh docker-ce-18.09.8-3.el7.x86_64.rpm rpm -ivh docker-ce-cli-18.09.8-3.el7.x86_64.rpm
7 配置docker 的阿里云加速器
容器镜像服务 (aliyun.com) 北京地区
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://q5bgvr7l.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
二、在线安装
1、查看安装过的docker:
yum list installed | grep docker docker.x86_64 2:1.13.1-74.git6e3bb8e.el7.centos docker-client.x86_64 2:1.13.1-74.git6e3bb8e.el7.centos docker-common.x86_64 2:1.13.1-74.git6e3bb8e.el7.centos
2、卸载docker
yum remove -y docker-ce.x86_64 docker-client.x86_64 docker-common.x86_64 yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-selinux \ docker-engine-selinux \ docker-engine ##慎重,会删除容器的数据 rm -rf /etc/systemd/system/docker.service.d rm -rf /var/lib/docker rm -rf /var/run/docker rm -rf /var/lib/docker
或者
yum -y remove docker-ce docker-common docker-selinux docker-engine
3、列出docker可用版本、搜索软件
yum list docker-ce --showduplicates | sort -r yum search docker
4、添加源、指定版本安装
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/ yum install docker-ce-19.03.6 docker-ce-cli-19.03.6 -y
5、建立 Docker 用户组
groupadd docker usermod -aG docker $USER