Docker daemon已运行但无法连接,拉取镜像失败求助
docker pull It looks like your Docker client is trying to connect to a Docker daemon running on a virtual machine at tcp://192.168.99.102:2376—this is typical if you’re using Docker Toolbox (which relies on a VirtualBox VM) instead of Docker Desktop’s native local daemon. Let’s walk through targeted fixes since you’ve already tried basic steps like restarting the service and using sudo:
Step 1: Check Docker Machine VM Status
First, confirm the underlying VM is running and accessible:
- List your Docker Machine instances to verify the VM state:
docker-machine ls - Look for the VM linked to
192.168.99.102(usually nameddefault). If its status showsStopped, start it with:docker-machine start default - Load the required environment variables to point your Docker client to this VM:
This setseval $(docker-machine env default)DOCKER_HOST,DOCKER_TLS_VERIFY, andDOCKER_CERT_PATHto the correct values for the VM.
Step 2: Clear Stale Environment Variables (If Using Docker Desktop)
If you switched from Docker Toolbox to Docker Desktop, leftover environment variables might force the client to connect to the wrong daemon:
- Clear the conflicting variables:
unset DOCKER_HOST DOCKER_TLS_VERIFY DOCKER_CERT_PATH - Close and reopen your terminal to apply the change, then try the
docker pullcommand again.
Step 3: Validate TLS Certificates
Port 2376 uses TLS encryption, so missing or corrupted certificates can block connections:
- Check if your certificate path is correctly configured:
It should point to a path likeecho $DOCKER_CERT_PATH~/.docker/machine/machines/default. - If certificates are missing or corrupted, regenerate them:
docker-machine regenerate-certs default - Reload the environment variables again with
eval $(docker-machine env default)and test the pull command.
Step 4: Test Direct Connection with Manual TLS Params
If the above steps fail, manually specify the daemon address and certificates to rule out environment issues:
docker -H tcp://192.168.99.102:2376 \ --tlsverify \ --tlscacert=~/.docker/machine/machines/default/ca.pem \ --tlscert=~/.docker/machine/machines/default/cert.pem \ --tlskey=~/.docker/machine/machines/default/key.pem \ pull osixia/phpldapadmin:latest
Step 5: Check Network/Firewall Blockages
- Verify you can ping the VM IP to confirm network connectivity:
If ping fails, restart the VM withping 192.168.99.102docker-machine restart defaultor check VirtualBox’s network settings for the VM. - Temporarily disable your local firewall (e.g.,
sudo ufw disableon Ubuntu) to rule out port blocking, then test the pull command again. Remember to re-enable the firewall afterward.
内容的提问来源于stack exchange,提问作者Juan David Porras Palencia

