CentOS 7.9 离线安装 Docker

在 CentOS 7.9 上安装 Docker 还是挺简单的,跟安装别的软件差不多,基本上也是老三样:下载文件,解压、配置环境变量, 配置服务脚本。
下面就来快速看下具体细节:

  1. 下载文件

    https://download.docker.com/linux/static/stable/x86_64/docker-20.10.9.tgz
    
    
  2. 解压、配置环境变量

    tar -xvf docker-20.10.9.tgz -C /opt/
    
    # 将可执行文件放在 /usr/bin 下可省去配置环境变量,生产环境暂不建议这么使用
    cp /opt/docker/* /usr/bin/
    
    
  3. 配置服务脚本

    vim /etc/systemd/system/docker.service

    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network-online.target firewalld.service
    Wants=network-online.target
      
    [Service]
    Type=notify
    ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=127.0.0.1
    ExecReload=/bin/kill -s HUP $MAINPID
    LimitNOFILE=infinity
    LimitNPROC=infinity
    LimitCORE=infinity
    TimeoutStartSec=0
    Delegate=yes
    KillMode=process
    Restart=on-failure
    StartLimitBurst=3
    StartLimitInterval=60s
      
    [Install]
    WantedBy=multi-user.target
    
    

    设置开机启动

    
    [root@node108 opt]# ll /etc/systemd/system/docker.service 
    -rwxrwxrwx. 1 root root 1198 Oct 22 11:18 /etc/systemd/system/docker.service
    [root@node108 opt]# systemctl daemon-reload  
    [root@node108 opt]# systemctl enable docker.service
    Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /etc/systemd/system/docker.service.
    
    

    验证是否可以正确启动

    [root@node108 opt]# systemctl start docker
    [root@node108 opt]# 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 2022-10-22 11:19:33 EDT; 5s ago
         Docs: https://docs.docker.com
     Main PID: 16238 (dockerd)
        Tasks: 15
       Memory: 30.7M
       CGroup: /system.slice/docker.service
               ├─16238 /usr/bin/dockerd --selinux-enabled=false --insecure-registry=127.0.0.1
               └─16243 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
    
    Oct 22 11:19:32 node108 dockerd[16238]: time="2022-10-22T11:19:32.811050263-04:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containe... module=grpc
    Oct 22 11:19:32 node108 dockerd[16238]: time="2022-10-22T11:19:32.811055654-04:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
    Oct 22 11:19:32 node108 dockerd[16238]: time="2022-10-22T11:19:32.818039023-04:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
    Oct 22 11:19:32 node108 dockerd[16238]: time="2022-10-22T11:19:32.832913520-04:00" level=info msg="Loading containers: start."
    Oct 22 11:19:32 node108 dockerd[16238]: time="2022-10-22T11:19:32.930173146-04:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daem... IP address"
    Oct 22 11:19:32 node108 dockerd[16238]: time="2022-10-22T11:19:32.961657503-04:00" level=info msg="Loading containers: done."
    Oct 22 11:19:33 node108 dockerd[16238]: time="2022-10-22T11:19:33.050149793-04:00" level=info msg="Docker daemon" commit=79ea9d3 graphdriver(s)=overlay2 version=20.10.9
    Oct 22 11:19:33 node108 dockerd[16238]: time="2022-10-22T11:19:33.050196710-04:00" level=info msg="Daemon has completed initialization"
    Oct 22 11:19:33 node108 systemd[1]: Started Docker Application Container Engine.
    Oct 22 11:19:33 node108 dockerd[16238]: time="2022-10-22T11:19:33.076929072-04:00" level=info msg="API listen on /var/run/docker.sock"
    Hint: Some lines were ellipsized, use -l to show in full.
    [root@node108 opt]# 
    
    
posted @ 2022-10-22 23:30  人间词话  阅读(419)  评论(0)    收藏  举报