【问题标题】:How to configure systemctl service for docker installed from binaries?如何为从二进制文件安装的 docker 配置 systemctl 服务?
【发布时间】:2021-10-20 01:52:26
【问题描述】:

我从 SLES 15 x86_64 (https://docs.docker.com/engine/install/binaries/#install-static-binaries) 上的二进制文件安装了 docker。现在我需要在启动和无根启动时配置引导。但我没有 docker.service。而且我不明白如何手动配置它。

谢谢。

【问题讨论】:

    标签: linux docker opensuse systemctl sles


    【解决方案1】:

    通常我建议启用Container Module 12 x86_64(又名sle-module-containers/12/x86_64),如here 所述,但我认为您有不使用它的理由。

    您需要按照documentation 中的说明在/etc/systemd/system 文件夹中创建docker.servicedocker.socket 文件。

    docker.service 内容可以找到here,目前是:

    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network-online.target docker.socket firewalld.service containerd.service
    Wants=network-online.target containerd.service
    Requires=docker.socket
    
    [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 fd:// --containerd=/run/containerd/containerd.sock
    ExecReload=/bin/kill -s HUP $MAINPID
    TimeoutStartSec=0
    RestartSec=2
    Restart=always
    
    # Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
    # Both the old, and new location are accepted by systemd 229 and up, so using the old location
    # to make them work for either version of systemd.
    StartLimitBurst=3
    
    # Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
    # Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
    # this option work for either version of systemd.
    StartLimitInterval=60s
    
    # 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
    
    # Comment TasksMax if your systemd version does not support it.
    # Only systemd 226 and above support this option.
    TasksMax=infinity
    
    # 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
    OOMScoreAdjust=-500
    
    [Install]
    WantedBy=multi-user.target
    

    docker.service 可以找到here,目前是:

    [Unit]
    Description=Docker Socket for the API
    
    [Socket]
    # If /var/run is not implemented as a symlink to /run, you may need to
    # specify ListenStream=/var/run/docker.sock instead.
    ListenStream=/run/docker.sock
    SocketMode=0660
    SocketUser=root
    SocketGroup=docker
    
    [Install]
    WantedBy=sockets.target
    

    【讨论】:

      猜你喜欢
      • 2020-08-22
      • 2022-06-13
      • 2018-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-12
      • 1970-01-01
      相关资源
      最近更新 更多