When working with Docker on macOS, many developers encounter connection issues where Docker commands fail with EOF errors. The root cause typically stems from incorrect DOCKER_HOST environment variable configuration and VM communication problems.
$ docker run ubuntu echo hello world
2014/06/17 08:20:54 Post http://localhost:4243/v1.12/containers/create: EOF
First, confirm your installation status:
$ boot2docker version
Client version: v1.0.0
Git commit: 2fef7b2
$ boot2docker status
[2014-06-17 08:26:24] boot2docker-vm is running.
The most common solution involves correctly setting the DOCKER_HOST variable:
$ export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375
To make this permanent, add it to your shell configuration:
echo "export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375" >> ~/.bash_profile
source ~/.bash_profile
If port 2375 doesn't work, try the alternative Docker port:
$ export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):4243
Verify the Docker daemon is listening on the correct port inside the VM:
$ boot2docker ssh
$ sudo netstat -ntpl | grep docker
tcp 0 0 :::2375 :::* LISTEN 743/docker
If issues persist, follow this checklist:
1. Restart the boot2docker VM:
$ boot2docker restart
2. Verify the VM IP:
$ boot2docker ip
3. Test direct connection to Docker port:
$ telnet $(boot2docker ip) 2375
4. Check Docker daemon logs inside VM:
$ boot2docker ssh
$ tail -f /var/log/docker.log
For newer macOS versions, consider using Docker Desktop instead of boot2docker:
$ brew install --cask docker
Docker Desktop includes proper native integration and eliminates these configuration issues.
When running Docker commands on Mac OS X after installing boot2docker, you're encountering EOF errors and connection failures. The fundamental issue stems from incorrect DOCKER_HOST configuration and port mismatches between client and VM.
First verify your environment with these commands:
# Check boot2docker version
boot2docker version
# Verify VM status
boot2docker status
# Check Docker client version
docker --version
The key issue appears in the conflicting port numbers:
# Incorrect default (shown in boot2docker up output)
export DOCKER_HOST=tcp://:4243
# Correct port should be 2375 (Docker default)
export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375
Here's the complete correct workflow:
# Initialize the VM (only needed once)
boot2docker init
# Start the VM
boot2docker up
# Set correct environment variables
export DOCKER_HOST=tcp://$(boot2docker ip):2375
export DOCKER_TLS_VERIFY=1
export DOCKER_CERT_PATH=~/.boot2docker/certs/boot2docker-vm
# Verify connection
docker run ubuntu echo hello world
If problems persist, try these diagnostic steps:
# Check VM's Docker daemon
boot2docker ssh "sudo netstat -ntpl | grep docker"
# Verify port accessibility
nc -zv $(boot2docker ip) 2375
# Reset Docker certificates
boot2docker delete
boot2docker init
boot2docker up
Remember that on Mac OS X, Docker runs inside a Linux VM (boot2docker). The client on your Mac communicates with the Docker daemon in the VM through TCP. This explains why docker -d
fails on Mac directly.
If using newer Docker for Mac (post-2016):
# No need for manual port configuration
docker run hello-world
# Check native Docker settings
docker context ls