In order to access the Docker API when running boot2docker, there are only a few things that you need to do:
Set up VirtualBox Port Forwarding
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port2375,tcp,,2375,,2375";
Disable TLS
boot2docker ssh
docker@boot2docker:~$ sudo echo "DOCKER_TLS=no" > /var/lib/boot2docker/profile
docker@boot2docker:~$ exit
boot2docker restart
At this point, boot2docker should tell you that you need to reset your environment variables:
export DOCKER_HOST=tcp://192.168.59.103:2375
unset DOCKER_TLS_VERIFY
unset DOCKER_CERT_PATH
After running these commands, you should be able to hit one of Docker’s APIs running inside of the VirtualBox VM managed via boot2docker with curl:
curl http://192.168.59.103:2375/info
Sources:
Boot2Docker Workarounds