Fix Docker Suddenly Not Working on Mac

Published: August 26, 2025  |  Categories: Docker, Mac, Troubleshooting

Warning: Some steps below will delete all your Docker containers and their data. Back up anything important before proceeding.

Docker Desktop on macOS can suddenly stop launching, freeze on startup, or become completely unresponsive — often after an OS update, a system crash, or a period of heavy use. This guide covers the most common causes and walks through a systematic fix from least destructive to most destructive.


How Docker Works on Mac (Background)

Unlike Linux, macOS doesn't have a native Linux kernel. Docker Desktop on Mac runs a lightweight Linux virtual machine (VM) under the hood using Apple's Hypervisor framework. All your containers run inside that VM.

This architecture means there are more moving parts that can break:

  • The VM itself might fail to start
  • The socket Docker clients talk to might not be created
  • File-sharing mounts between macOS and the VM might go stale
  • The Docker daemon inside the VM might crash

Understanding this helps you diagnose which layer is broken.


Prerequisites

  • macOS with Docker Desktop installed
  • Terminal access
  • Admin (sudo) privileges

Quick Checks First

Before doing anything destructive, try these fast checks:

Check if Docker daemon is actually running:

docker info

If you get Cannot connect to the Docker daemon — the daemon isn't running. If you get output, Docker is alive and the issue is elsewhere.

Check Docker Desktop logs:

tail -100 ~/Library/Containers/com.docker.docker/Data/log/vm/dockerd.log

Look for obvious error messages. This often tells you exactly what's wrong.

Check available disk space:

df -h ~

Docker's VM needs free space to operate. Less than 2 GB free can cause startup failures.


Step 1: Force Quit Docker

If Docker Desktop is frozen and won't quit normally:

  1. Open Activity Monitor (Applications > Utilities > Activity Monitor)
  2. Search for Docker
  3. Select Docker Desktop and click the Force Quit (X) button

Alternatively, from the terminal:

pkill -f Docker

Wait 5–10 seconds after killing it before trying to relaunch.


Step 2: Restart Docker Normally First

Before wiping anything, try a clean restart:

open -a Docker

Wait up to 2 minutes. If the whale icon in the menu bar stops animating and turns solid, Docker started successfully. Run docker ps to confirm. If it's still stuck after 2 minutes, proceed to the next steps.


Step 3: Remove Docker Container Files

This removes corrupted container data and resets Docker's internal state.

sudo rm -rf ~/Library/Containers/com.docker.*
What this does: Deletes all Docker container storage under your user library. This is irreversible — all stopped and running containers, their volumes, and their internal state will be gone after this step.

Step 4: Clear File Sharing Directories in Docker Settings

Docker's settings file sometimes references directories that no longer exist. This causes the VM to hang during startup as it tries to mount unavailable paths.

Open the settings file:

sudo nano ~/Library/Group\ Containers/group.com.docker/settings.json

Find the "filesharingDirectories" key and clear its array:

"filesharingDirectories": []

Save the file (Ctrl+O, then Enter) and exit (Ctrl+X). You can re-add your desired shared directories from Docker Desktop's Settings > Resources > File Sharing after it starts.


Step 5: Restart Docker and Verify

Launch Docker Desktop from your Applications folder. The first startup after a reset can take 60–90 seconds. Once Docker is running, verify it works:

docker run hello-world

You should see a "Hello from Docker!" message confirming everything is working.


Step 6: Full Uninstall and Reinstall (Last Resort)

If Docker still won't start, do a complete clean uninstall. If Docker Desktop won't open at all, remove it manually:

# Remove the app
sudo rm -rf /Applications/Docker.app

# Remove all data and config
rm -rf ~/Library/Group\ Containers/group.com.docker
rm -rf ~/Library/Containers/com.docker.docker
rm -rf ~/.docker
sudo rm -f /usr/local/bin/docker
sudo rm -f /usr/local/bin/docker-compose

Then download and reinstall the latest Docker Desktop from docker.com.


Why Does This Happen?

CauseWhat Breaks
macOS updateHypervisor permissions, kernel extensions
Abrupt shutdown / crashDocker's internal database gets corrupted
Renamed/deleted directoriesFile-sharing paths in settings become stale
Disk space fullVM can't write to its virtual disk
Docker Desktop auto-updatePartial update leaves inconsistent state
VPN software conflictVPN changes network interfaces Docker relies on

Common Error Messages and What They Mean

dial unix docker.raw.sock: connect: no such file or directory
→ Docker daemon is not running. Restart Docker Desktop.

Error response from daemon: OCI runtime create failed
→ Usually a permissions or disk space issue. Check df -h.

docker: command not found
→ Docker CLI is not in your PATH after reinstall. Restart your terminal or run export PATH=$PATH:/usr/local/bin.


Alternative: Use Colima Instead

If Docker Desktop keeps giving you trouble on Mac, consider Colima — a lightweight, open-source container runtime for macOS. It uses the same Docker CLI but without Docker Desktop's overhead:

brew install colima docker
colima start
docker run hello-world

Colima is free, uses less RAM, and starts faster than Docker Desktop for most development workflows.


References

Cannot Import XGBoost in Jupyter Notebook

Published: October 16, 2024  |  Categories: Python, Jupyter, Machine Learning

XGBoost is one of the most widely used machine learning libraries — it's behind many winning Kaggle solutions and is a go-to for structured data problems. But it has a frustrating quirk: on some systems, especially macOS, it fails to import with a cryptic error about a missing runtime library. This post explains why it happens and how to fix it on every platform.


The Error

You'll see something like this when running import xgboost:

XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.
Likely causes:
  * OpenMP runtime is not installed
    - vcomp140.dll or libgomp-1.dll for Windows
    - libomp.dylib for Mac OSX
    - libgomp.so for Linux and other UNIX-like OSes
  * You are running 32-bit Python on a 64-bit OS

Why This Happens

XGBoost uses OpenMP (Open Multi-Processing) to run computations in parallel across CPU cores. OpenMP is not part of Python or XGBoost itself — it's a separate shared library that XGBoost expects to find on the system at runtime.

The problem is that OpenMP isn't installed by default on:

  • Fresh macOS installs (Apple's Clang compiler doesn't bundle it)
  • New virtual environments (Python envs don't carry system libraries)
  • Minimal Linux containers (stripped-down Docker images often omit it)

When XGBoost starts and tries to load the OpenMP shared library, it can't find it — and fails with the error above.


Fix on macOS

Install the missing OpenMP runtime via Homebrew:

brew install libomp

If Homebrew isn't installed yet, run this first:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

After installing libomp, restart your Jupyter kernel — not just the cell, the whole kernel. Go to Kernel > Restart in the menu.

Why kernel restart matters: Python caches import failures in the current session. Even after installing the missing library, the import will keep failing until you start a fresh Python process. Rerunning the cell isn't enough — you must restart the kernel.

Then try importing again:

import xgboost as xgb
print(xgb.__version__)

Fix on Windows

On Windows the import error is caused by a missing Visual C++ runtime:

  1. Go to the Microsoft Visual C++ Redistributable page
  2. Download the x64 version (vc_redist.x64.exe)
  3. Install it and restart your machine
  4. Try importing XGBoost again

If that doesn't work, try reinstalling via pip:

pip uninstall xgboost
pip install xgboost

Fix on Linux

Install libgomp via your package manager:

# Ubuntu / Debian
sudo apt-get update && sudo apt-get install libgomp1

# CentOS / RHEL
sudo yum install libgomp

# Fedora
sudo dnf install libgomp

# Alpine (e.g. in Docker)
apk add libgomp

Check Which Python Jupyter Is Using

The most common hidden cause of this error is an environment mismatch: XGBoost is installed in one Python environment, but Jupyter is running from a different one.

Check which Python your Jupyter kernel is using:

import sys
print(sys.executable)

Then check if XGBoost is installed in that environment:

/path/to/your/python -c "import xgboost; print(xgboost.__version__)"

If XGBoost is installed but not in the path Jupyter is using, reinstall it in the correct environment:

/path/to/your/python -m pip install xgboost

Using Conda?

If you're using a conda environment, install XGBoost through conda rather than pip — conda resolves the native library dependencies automatically:

conda install -c conda-forge xgboost

Verifying the Fix

Once XGBoost imports successfully, run a quick sanity check:

import xgboost as xgb
import numpy as np

X = np.random.rand(100, 5)
y = np.random.randint(0, 2, 100)

model = xgb.XGBClassifier(n_estimators=10, eval_metric='logloss')
model.fit(X, y)
print("XGBoost is working correctly. Version:", xgb.__version__)

If this runs without errors, you're good to go.


Summary

PlatformRoot CauseFix
macOSMissing libomp.dylibbrew install libomp
WindowsMissing Visual C++ runtimeInstall VC++ Redistributable
LinuxMissing libgomp.sosudo apt-get install libgomp1
AnyEnvironment mismatchCheck sys.executable, reinstall in correct env
AnyStale import cacheRestart Jupyter kernel after installing

The fix is almost always a one-liner. The tricky part is knowing that you need to restart the kernel — not just re-run the cell — after making any changes.