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

CentOS7下如何启动Docker守护进程而不启动自动重启容器?

Fix: Start Docker Daemon Without Launching Containers on CentOS 7

Absolutely, Docker has a built-in way to start the daemon without launching any containers—perfect for your scenario where a misbehaving auto-restart container is blocking the daemon from fully starting up. Here are two reliable methods to resolve this:

Method 1: Manual Daemon Start with --no-startup-containers

This is the cleanest and most direct approach:

  1. Kill stuck Docker processes
    First, stop the hung Docker service and any lingering daemon processes:

    systemctl stop docker
    # If the daemon is still running, locate and terminate it
    ps aux | grep dockerd
    kill -9 <PID_of_dockerd>
    
  2. Launch the daemon without container startup
    Run the Docker daemon directly with the --no-startup-containers flag to skip launching all containers (even those set to auto-restart):

    dockerd --no-startup-containers
    

    The daemon will fully start up without attempting to load any containers, letting you access the Docker CLI normally.

  3. Fix the problematic container
    Open a new terminal window (keep the manual dockerd process running), then:

    • List all containers to identify the one causing issues:
      docker ps -a
      
    • Disable auto-restart for the problematic container to prevent future blocks:
      docker update --restart=no <container_name_or_id>
      
  4. Restart Docker normally
    Stop the manual dockerd process (press Ctrl+C in its terminal), then start the service as usual:

    systemctl start docker
    

Method 2: Temporarily Hide Container Metadata (Fallback)

If the flag method doesn’t work for some reason, you can temporarily move container configs to force Docker to start empty:

  1. Stop Docker and move the containers directory

    systemctl stop docker
    mv /var/lib/docker/containers /var/lib/docker/containers.bak
    
  2. Start Docker normally

    systemctl start docker
    

    Docker will start without any containers since it can’t find the metadata files.

  3. Restore and resolve the issue
    Stop Docker again, move the directory back, then use the --no-startup-containers flag to fix the problematic container:

    systemctl stop docker
    mv /var/lib/docker/containers.bak /var/lib/docker/containers
    dockerd --no-startup-containers
    # Run docker update --restart=no <container_id> as before
    

Note: Always back up the /var/lib/docker directory before modifying it to avoid accidental data loss.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 08:10:21