yum方式安装
- 安装依赖
[root@lucky ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
- 添加仓库
[root@lucky ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo [root@iZrj987jhi4cl38mj8px0eZ ~]# dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
- 安装最新版本的 Docker Engine-Community 和 containerd
[root@lucky ~]# yum install docker-ce docker-ce-cli -y
- 启动服务
[root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl start docker [root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl enable docker Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
- 配置镜像加速器
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo mkdir -p /etc/docker [root@iZrj987jhi4cl38mj8px0eZ ~]# sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://00s5k4m1.mirror.aliyuncs.com"] } EOF [root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl daemon-reload [root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl restart docker
RPM 安装
- 下载docker-ce-cli
[root@iZrj987jhi4cl38mj8px0eZ ~]# wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-19.03.9-3.el7.x86_64.rpm [root@iZrj987jhi4cl38mj8px0eZ ~]# yum install docker-ce-cli-19.03.9-3.el7.x86_64.rpm -y
- 下载docker
[root@iZrj987jhi4cl38mj8px0eZ ~]# wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-19.03.9-3.el7.x86_64.rpm [root@iZrj987jhi4cl38mj8px0eZ ~]# dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm [root@iZrj987jhi4cl38mj8px0eZ ~]# yum install -y docker-ce-19.03.9-3.el7.x86_64.rpm
- 启动服务
[root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl start docker [root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl enable docker Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
- 加速器
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo mkdir -p /etc/docker [root@iZrj987jhi4cl38mj8px0eZ ~]# sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://00s5k4m1.mirror.aliyuncs.com"] } EOF [root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl daemon-reload [root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl restart docker
二进制安装
[root@iZrj987jhi4cl38mj8px0eZ ~]# wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.9.tgz [root@iZrj987jhi4cl38mj8px0eZ ~]# tar zxf docker-19.03.9.tgz [root@iZrj987jhi4cl38mj8px0eZ ~]# cp -a docker/* /usr/bin/ [root@iZrj987jhi4cl38mj8px0eZ ~]# chmod 755 /usr/bin/{containerd,containerd-shim,ctr,docker,dockerd,docker-init,docker-proxy,runc}
- 创建docker的systemd unit文件
[root@iZrj987jhi4cl38mj8px0eZ ~]# vim /etc/systemd/system/docker.service [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service containerd.service Wants=network-online.target [Service] Type=notify ExecStart=/usr/bin/dockerd 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
- 启动
[root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl daemon-reload [root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl start docker [root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl enable docker Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /etc/systemd/system/docker.service. [root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2020-06-13 16:34:56 CST; 12s ago Docs: https://docs.docker.com Main PID: 3093 (dockerd) Tasks: 18 Memory: 30.9M CGroup: /system.slice/docker.service ├─3093 /usr/bin/dockerd └─3100 containerd --config /var/run/docker/containerd/containerd.toml --log-level info 6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.016942822+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc 6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.087396381+08:00" level=warning msg="Your kernel does not support cgroup blkio weight" 6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.087429346+08:00" level=warning msg="Your kernel does not support cgroup blkio weight_device" 6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.087604192+08:00" level=info msg="Loading containers: start." 6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.335135110+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip > 6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.450708028+08:00" level=info msg="Loading containers: done." 6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.518093214+08:00" level=info msg="Docker daemon" commit=9d988398e7 graphdriver(s)=overlay2 version=19.03.9 6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.518515655+08:00" level=info msg="Daemon has completed initialization" 6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.557843966+08:00" level=info msg="API listen on /var/run/docker.sock" 6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ systemd[1]: Started Docker Application Container Engine.
- 配置镜像加速
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo mkdir -p /etc/docker [root@iZrj987jhi4cl38mj8px0eZ ~]# sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://00s5k4m1.mirror.aliyuncs.com"] } EOF [root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl daemon-reload [root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl restart docker
继续阅读
- 我的QQ
- QQ扫一扫
-
- 我的头条
- 头条扫一扫
-
评论