Not able to access docker daemon api from docker container

I have vagrant box running with docker daemon and on same box I have a docker container running.

From docker container, I am trying to curl http://<IP-of-virtualbox>:2375/version and it’s not able to connect. Getting the message connection refused

  • Why so many layers on base images? Docker
  • How to make docker container to be accessed only in intranet
  • crontab not executing on centos7 container
  • How can I create a Docker image based on a git tag in the public Registry?
  • How do share a directory with same name in the current directory with docker
  • Dotnet Core publish to IIS from Mac
  • But from host machine I can curl http://<IP-of-virtualbox>:2375/version, not only from container.

  • How can my friend and I share an exact development environment together while on different operating systems?
  • AWS Elastic Beanstalk Docker PHP application
  • Fluent docker tail vs docker fluentd logging driver
  • How to pass the Docker CLI Arguments when starting a container using Kubernetes
  • Mappings between Docker Remote API and its command line client
  • Does docker run -v or Dockerfile VOLUME take precedence?
  • One Solution collect form web for “Not able to access docker daemon api from docker container”

    Your docker container doesn’t know how to get to the <IP-of-virtualbox-machine>. The containers run a different subnet, if you are using one of the latest versions of Docker it should be the same subnet as your docker0 interface on the VirtualBox VM where you are running the docker daemon.

    For example for this docker daemon VirtualBox VM:

    docker@default:~$ ifconfig
    docker0   Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
              inet addr:A.B.C.D  Bcast:0.0.0.0  Mask:255.255.0.0
              inet6 addr: ffff::ff:ffff:ffff:ffff/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:546 errors:0 dropped:0 overruns:0 frame:0
              TX packets:1091 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:26832 (26.2 KiB)  TX bytes:2734357 (2.6 MiB)
    

    and this container:

    user@45b26c832418:~# ifconfig
    eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
              inet addr:A.B.C.E  Bcast:0.0.0.0  Mask:255.255.0.0
              inet6 addr: ffff::ff:ffff:ffff:1/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:11 errors:0 dropped:2 overruns:0 frame:0
              TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:926 (926.0 B)  TX bytes:598 (598.0 B)
    

    you can run the following from the container:

    curl http://A.B.C.D:2375/status
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.