Linux 安装docker

您所在的位置:网站首页 mirrorce修改教程 Linux 安装docker

Linux 安装docker

2023-02-25 11:46| 来源: 网络整理| 查看: 265

            Linux 安装docker-ce版本后使用脚本速配国内阿里镜像加速

众所周知,docker三要素是仓库,镜像,容器。仓库的重要性不用多说,docker的基础镜像包都是通过 docker pull 命令来安装,安装完docker后,默认pull镜像是国外的镜像站,由于服务器距离国内遥远以及墙的原因,pull成功的几率比较低并且也很慢,耗费时间。国内几大云计算厂商都有docker镜像加速服务,阿里云的速度以及可靠性毋庸置疑。因此编写了一个简单的脚本,实现快速docker pull指向阿里云,下面上代码:

#!/bin/bashcp /usr/lib/systemd/system/docker.service /etc/systemd/system/sed -i '/ExecStart/d' /etc/systemd/system/docker.servicesed -i '13a ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --registry-mirror=https://b0j89uo8.mirror.aliyuncs.com -H unix:///var/run/docker.sock' /etc/systemd/system/docker.servicesystemctl daemon-reloadsystemctl restart docker

该脚本结构十分简单,五行命令,第一步,拷贝docker的启动脚本,第二步,删除文件内关于docker启动的参数,第三步,重新写入docker启动参数,第四步,重载该配置文件,第五步,重启docker服务。

总结:脚本赋予执行权限,执行即可,检查是否生效的方法如下:

执行命令  docker info,在该命令的输出最后可以看到 ​​https://b0j89uo8.mirror.aliyuncs.com​​

 

[root@1111 ~]# docker info Client: Debug Mode: falseServer: Containers: 7 Running: 0 Paused: 0 Stopped: 7 Images: 3 Server Version: 19.03.11 Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 3.10.0-1127.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 3.858GiB Name: centos1 ID: 2J2X:3QTU:55NJ:GYS3:EOBB:DH4T:ZBBY:IW4S:SN7D:BDX5:RLQ4:GD5N Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Registry Mirrors: https://b0j89uo8.mirror.aliyuncs.com/ #有这个就是证明速配成功了 Live Restore Enabled: false


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3