Skip to content
TheChatArchiveThe Chat Archive
Geminigemini-2.5-flash· GoogleHugging Face LMArena Human Preference 140K

docker rootles: mkdir /var/lib/docker/network: permission denied

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-3-7-sonnet-20250219’s answer.
  1. User

    docker rootles: mkdir /var/lib/docker/network: permission denied

  2. Gemini Assistant

    This error mkdir /var/lib/docker/network: permission denied when running Docker in rootless mode is a strong indicator of a misconfiguration or misunderstanding of how rootless Docker works.

    Why this happens:

    Rootless Docker does not use /var/lib/docker for its data directory. That path is reserved for the traditional, root-privileged Docker daemon.

    When you run Docker in rootless mode, its data is stored in your user's home directory, typically at ~/.local/share/docker (or ~/.docker in older setups).

    The error means that your Docker client (or possibly the rootless daemon itself) is trying to operate on the standard /var/lib/docker path, which your non-root user doesn't have permission to write to.

    Most Likely Causes and Solutions:

    1. DOCKER_HOST Environment Variable is Pointing to the Wrong Socket: This is by far the most common cause. Your client might be trying to connect to the system-wide (rootful) Docker daemon's socket, instead of your user-specific (rootless) daemon's socket.

      • Check it:
        echo $DOCKER_HOST
        
      • Expected for Rootless: It should either be unset (so it defaults to the rootless socket) or explicitly set to something like unix:///run/user/$(id -u)/docker.sock.
      • Problematic: If it's unix:///var/run/docker.sock or empty while a rootful daemon is running, your client will try to talk to the rootful daemon.
      • Solution:
        unset DOCKER_HOST
        
        Then try your Docker command again. When DOCKER_HOST is unset, Docker will look for the default rootless socket if a rootless daemon is running, or the default rootful socket if not.
    2. Rootless Docker Daemon is Not Running or Not Configured Correctly: Even if your DOCKER_HOST is correct, the rootless daemon itself might not be running.

      • Check if it's running (using systemd user service):
        systemctl --user status docker
        
        It should show as active (running). If not, start it:
        systemctl --user start docker
        systemctl --user enable docker  # To start on login
        
      • Verify Rootless Status:
        docker info | grep "Rootless"
        
        It should output Rootless: true. If it's false or the command fails, your setup isn't properly rootless.
    3. Conflicting Rootful Docker Daemon: If you also have a traditional root-privileged Docker daemon running alongside your rootless setup, and your DOCKER_HOST is accidentally pointing to it, then you'll get this error.

      • Check if a rootful daemon is running:
        sudo systemctl status docker
        
      • Action: If you intend to only use rootless Docker, consider disabling or stopping the rootful one to avoid confusion. If you need both, always ensure your DOCKER_HOST points to the correct one for the tasks you're performing.
    4. Incomplete or Incorrect Rootless Installation: If you didn't follow the official rootless installation steps (e.g., using dockerd-rootless-setuptool.sh), your environment might not be set up correctly.

      • Review the official guide: Refer to the Docker documentation for "Run the Docker daemon as a non-root user (Rootless mode)". The dockerd-rootless-setuptool.sh script usually handles setting up the DOCKER_HOST for your session and configuring the systemd --user unit.

    Troubleshooting Steps (in order):

    1. unset DOCKER_HOST: This is the quickest and most common fix.

      unset DOCKER_HOST
      docker run hello-world # Test it
      
    2. Verify Rootless Daemon Status:

      systemctl --user status docker
      

      If not running, start it:

      systemctl --user start docker
      
    3. Check docker info:

      docker info | grep "Rootless"
      docker info | grep "Docker Root Dir"
      

      Rootless: true is good. Docker Root Dir should be in your home directory (e.g., /home/youruser/.local/share/docker). If it's /var/lib/docker, something is deeply wrong with your rootless setup.

    4. Restart your terminal session or log out/in: Sometimes environment variables from previous sessions or system-wide configurations can persist. A fresh session ensures a clean environment.

    By following these steps, you should be able to resolve the "permission denied" error and get your rootless Docker setup working correctly.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.