You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Debian系统下Docker服务无法通过systemctl启动的修复求助

Fix Docker Systemd Service After VM Crash

Looks like your docker.service file got corrupted during the VM crash—right now it only has the environment variable line, missing all the required systemd service sections that tell systemd how to start/stop Docker. That's exactly why you're seeing those "Assignment outside of section" and "lacks ExecStart/ExecStop" errors.

Here's how to fix it step by step:

  1. Backup the broken file first (just in case):

    sudo cp /lib/systemd/system/docker.service /lib/systemd/system/docker.service.bak
    
  2. Replace the corrupted service file with a valid one
    Open the file with your favorite editor (I'll use nano here for simplicity):

    sudo nano /lib/systemd/system/docker.service
    

    Paste the following content (this matches the default Docker service config for Debian 9, plus your existing environment variable):

    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network-online.target firewalld.service containerd.service
    Wants=network-online.target
    Requires=containerd.service
    
    [Service]
    Type=notify
    ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
    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
    Environment="GOOGLE_APPLICATION_CREDENTIALS=/etc/docker/key.json"
    
    [Install]
    WantedBy=multi-user.target
    

    Save and exit: press Ctrl+O, hit Enter, then Ctrl+X.

  3. Reload systemd and restart Docker
    Tell systemd to pick up the new service config:

    sudo systemctl daemon-reload
    

    Now start Docker via systemctl:

    sudo systemctl start docker
    
  4. Verify everything works
    Check the service status to confirm it's running:

    sudo systemctl status docker
    

    If you want Docker to start automatically on boot, run:

    sudo systemctl enable docker
    

This restores the full, valid systemd service structure while keeping your GOOGLE_APPLICATION_CREDENTIALS environment variable—systemd will now know exactly how to manage the Docker service again.

内容的提问来源于stack exchange,提问作者DarkLeafyGreen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 07:58:11